coderatchet
coderatchet

Reputation: 8420

specifying the message listener interface of an MDB

I am trying to fully define my message driven beans using the deployment descriptor as I am deploying my app to Websphere and it doesn't handle annotations very nicely.

I'm wondering if there is a way of specifying the message listener interface of an MDB in the ejb-jar.xml file?

Upvotes: 0

Views: 3146

Answers (1)

Sai prateek
Sai prateek

Reputation: 11926

You must use the @javax.ejb.MessageDriven annotation to declare the EJB type as message-driven. You can specify the following optional attributes:

  1. messageListenerInterface—Specifies the message listener interface, if you haven't explicitly implemented it or if the bean implements additional interfaces.

The bean class must implement, directly or indirectly, the message listener interface required by the messaging type that it supports or the methods of the message listener interface. In the case of JMS, this is the javax.jms.MessageListener interface.

  1. activationConfig—Specifies an array of activation configuration properties that configure the bean in its operational environment.

Activation configuration properties are name-value pairs that are passed to the MDB container when an MDB is deployed. The properties can be declared in either an ejb-jar.xml deployment descriptor or by using the @ActivationConfigProperty annotation on the MDB bean class.

Activation Configuration Properties Set in ejb-jar.xml

<message-driven>
      . . .
      <activation-config>
        <activation-config-property>
            <activation-config-property-name>destinationJNDIName</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>
      . . .
    </message-driven>
    <message-driven>
      . . .
      <activation-config>
        <activation-config-property>
            <activation-config-property-name>destinationJNDIName</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>
      . . .
    </message-driven>

Upvotes: 2

Related Questions