You can use the Create an Enterprise Bean wizard to create EJB 2.0 or EJB 2.1 message-driven beans.
Message-driven beans were introduced in EJB 2.0 to support the processing of asynchronous messages from a Java Message Service (JMS). The EJB 2.1 specification expands the definition of the message-driven bean so that it can support any messaging system, not just JMS. Accordingly, the deployment descriptor elements used to define message-driven beans changed in the EJB 2.1 specification. The wizard for creating an EJB 2.1 message-driven bean also includes additional pages for optionally defining your non-JMS messaging system and its activation configuration elements.
The following 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.
<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>
<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.
To create an EJB 2.0 or EJB 2.1 message-driven bean: