0

在GlassFish應用服務器作爲本指南描述2.1我創建了一個GenericJMSRA與ActiveMQ的連接:http://activemq.apache.org/sjsas-with-genericjmsra.html使用帶註釋的GlassFish上的GenericJMSRA部署MDB?

我一直在使用注射用ejb-jar.xml中的上下文的經典方式成功能夠部署一個MDB :

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN'  'http://java.sun.com/dtd/ejb-jar_2_0.dtd'> 
<ejb-jar> 
    <enterprise-beans> 
    <message-driven> 
     <ejb-name>QueueListener</ejb-name> 
     <ejb-class>foo.QueueListenerMDB</ejb-class> 
     <transaction-type>Container</transaction-type> 
    </message-driven> 
    </enterprise-beans> 
</ejb-jar> 

和太陽ejb-jar.xml中

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE sun-ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Application Server 8.1 EJB 2.1//EN' 'http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-1.dtd'> 
<sun-ejb-jar> 
    <enterprise-beans> 
    <ejb> 
     <ejb-name>QueueListener</ejb-name> 
     <mdb-connection-factory> 
      <jndi-name>jms/amqQueueConnectionFactory</jndi-name> 
     </mdb-connection-factory> 
     <mdb-resource-adapter> 
     <resource-adapter-mid>activemqra</resource-adapter-mid> 
     <activation-config> 
      <activation-config-property> 
      <activation-config-property-name>DestinationType</activation-config-property-name> 
      <activation-config-property-value>javax.jms.Queue</activation-config-property-value> 
      </activation-config-property> 
      <activation-config-property> 
      <activation-config-property-name>destination</activation-config-property-name> 
      <activation-config-property-value>qRequest</activation-config-property-value> 
      </activation-config-property> 
     </activation-config> 
     </mdb-resource-adapter> 
    </ejb> 
    </enterprise-beans> 
</sun-ejb-jar> 

我將如何繼續注入上述配置中的註釋驅動的EJB 3.0的風格?更具體地說,它是以下屬性,我無法找到如何注入:

<resource-adapter-mid>activemqra</resource-adapter-mid> 

回答

0

終於得到它的工作。

我完全刪除了ejb-jar.xml,並保持sun-ejb-jar.xml不變。然後我註釋了類foo.QueueListenerMDB如下:

@MessageDriven(name = "QueueListener", mappedName = "QueueListener") 
public class QueueListenerMDB implements MessageListener { 
    ... 
}