我有简单的Message Driven Bean
@Named
@MessageDriven(mappedName = "jms/myQueue")
public class TestMDB implements MessageListener {
@Override
public void onMessage(Message msg) {
//...
}
}
如何仅使用部署描述符ejb-jar.xml而不是注释来实现相同的目标?我在编译时不知道队列的JNDI名称,所以我想在部署描述符中指定它。
答案 0 :(得分:0)
也许类似于:
<message-driven>
<ejb-name>TestMDB</ejb-name>
<ejb-class>package.name.TestMDB</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>myQueue</activation-config-property-value>
</activation-config-property>
<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>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>Auto-acknowledge</activation-config-property-value>
</activation-config-property>
</activation-config>
<resource-ref id="ResourceRef_0">
<res-ref-name>jms/myQCF</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</message-driven>
然后在bnd.xml文件中:
<message-driven name="TestMDB">
<jca-adapter activation-spec-binding-name="mdb30/myQueue" destination-binding-name="Jetstream/jms/myQueue" activation-spec-auth-alias=""/>
<resource-ref name="jms/myQCF" binding-name="Jetstream/jms/myQCF"/>
</message-driven>