Reputation: 473
I have simple Message Driven Bean
@Named
@MessageDriven(mappedName = "jms/myQueue")
public class TestMDB implements MessageListener {
@Override
public void onMessage(Message msg) {
//...
}
}
How can I achieve the same using only deployment descriptor ejb-jar.xml instead of annotations? I don't know queue's JNDI-name at compile time, so I want to specify it in deployment descriptor.
Upvotes: 2
Views: 1207
Reputation: 2084
Maybe something similar to:
<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>
Then in the bnd.xml file:
<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>
Upvotes: 0