2

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.

Joel
  • 473
  • 2
  • 7
  • 22
  • You are tending to go backward. How are you getting your JNDI name at deploy time, not at runtime? To answer the question, you need to create a ejb-jar.xml and pack it. Read this http://www.adam-bien.com/roller/abien/entry/simplest_annotation_less_ejb_3 – Aninda Bhattacharyya Mar 11 '15 at 20:44

1 Answers1

0

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>
Ryan
  • 2,058
  • 1
  • 15
  • 29
  • I get `com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: MDB destination not specified.` Have I missed something? – Joel Mar 13 '15 at 07:50
  • Edited original post - maybe that can get you on the right track? – Ryan Mar 13 '15 at 18:32