Can we use ejb-jar.xml instead of annotations for MessageDrivenBean(MDB) in EJB 3.0?

Adheep Mohamed Abdul Kader picture Adheep Mohamed Abdul Kader · Jan 21, 2012 · Viewed 12k times · Source

I've configured the message destination type, name etc using @ActivationConfigProperty in EJB 3.0 but I wanted to configure the MDB using deployment descriptor (ejb-jar.xml) as in EJB 2.0.

FYI: I'm using JBoss 6

Can anyone guide me on this?

Answer

Adheep Mohamed Abdul Kader picture Adheep Mohamed Abdul Kader · Feb 20, 2012

Thanks man, but I've figured it out in a much simpler way. Below is the code

<ejb-jar id="ejb-jar_ID" version="3.1"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                          http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

  <display-name>SampleTransactionMDB</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>SampleTransactionMDB</display-name>
      <ejb-name>SampleTransactionMDB</ejb-name>
      <ejb-class>com.example.SampleTransactionMDB</ejb-class>
      <transaction-type>Container</transaction-type>
      <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>/queue/SampleTransactionQueue</activation-config-property-value>
        </activation-config-property> 
      </activation-config>
    </message-driven>  
  </enterprise-beans>
  <assembly-descriptor>
  </assembly-descriptor>
</ejb-jar>