Message-driven bean deployment descriptor examples

These code examples illustrate the differences between the EJB 2.0 and EJB 2.1 deployment descriptor elements that are used to define message-driven beans.

EJB 2.0

This code sample shows an EJB 2.0 message-driven bean description in the deployment descriptor:

<message-driven id="Mdb20">
  <ejb-name>Mdb</ejb-name>
  <ejb-class>ejbs.MdbBean</ejb-class>
  <transaction-type>Bean</transaction-type>
  <message-selector>mdbMessage</message-selector>
  <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
  <message-driven-destination>
    <destination-type>javax.jms.Topic</destination-type>
    <subscription-durability>Durable</subscription-durability>
  </message-driven-destination>
</message-driven>

EJB 2.1

This code sample shows an EJB 2.1 message-driven bean description in the deployment descriptor:

<message-driven id="Mdb21">
  <ejb-name>Foo</ejb-name>
  <ejb-class>ejbs.FooBean</ejb-class>
  <messaging-type>javax.jms.MessageListener</messaging-type>
  <transaction-type>Bean/transaction-type>
  <message-destination-type>javax.jms.Topic</message-destination-type>
  <activation-config>
    <activation-config-property>
      <activation-config-property-name>destinationType</activation-config-property-name>
      <activation-config-property-value>javax.jms.Topic</activation-config-property-value>
    </activation-config-property>
    <activation-config-property>
      <activation-config-property-name>subscriptionDurability</activation-config-property-name>
      <activation-config-property-value>Durable</activation-config-property-value>
    </activation-config-property>
    <activation-config-property>
      <activation-config-property-name>acknowledgeMode</activation-config-property-name>
      <activation-config-property-value>AutoAcknowledge</activation-config-property-value>
    </activation-config-property>
    <activation-config-property>
      <activation-config-property-name>messageSelector</activation-config-property-name>
      <activation-config-property-value>fooSelector</activation-config-property-value>
    </activation-config-property>
  </activation-config>
  </transaction-type>
</ejb-name>
</message-driven>

In EJB 2.1, the specification defines an <activation-config-property> element to be used for defining properties such as the acknowledge mode, message selector, subscription durability, and destination type. When you use a non-JMS messaging type, the wizard allows you to define the <activation-config-property> name and value pairs that you need to use for your bean. For a JMS messaging system, the wizard provides the default configuration properties required by JMS, such as subscriptionDurability and acknowledgeMode.


Feedback