users@glassfish.java.net

Re: Help with MDB deployment descriptor

From: Cheng Fang <cheng.fang_at_oracle.com>
Date: Thu, 27 Oct 2011 11:47:56 -0400

Nigel just reminded that the use of <message-destination-link> for this
purpose is still broken due to issue
http://java.net/jira/browse/GLASSFISH-7302

-cheng

On 10/26/11 8:24 PM, Cheng Fang wrote:
> <message-destination-ref> specifies a messaging resource that will be
> used by your MDB bean class during message processing (not receiving
> messaging). <message-destination-ref> is optional and your bean class
> may not need it for processing.
>
> To specify the messaging destination your bean class is listening to,
> use message-destination-link, which means you also need to declare a
> <message-destination> that you will link to it.
>
> Map the <message-destination> to its physical target in appserver with
> glassfish-web.xml or glassfish-ejb-jar.xml or glassfish-application.xml.
>
> -cheng
>
> On 10/26/11 2:01 PM, guru_gho_at_hotmail.com wrote:
>> I am searching for the best way to write the deployment descriptor file
>> for a MDB Bean.
>>
>> I saw examples instructing to write as mapped-name the JNDI name the
>> MDB will consume.
>> So, it may be used:
>>
>> <message-driven>
>> <ejb-name>ServiceActivator</ejb-name>
>> <mapped-name>jms/myQueue</mapped-name
>> </message-driven>
>>
>>
>> However, it may cause confusion to unexperienced deployers that does
>> not understand too well JMS technology.
>>
>> So, I tried an alternative approach where we can explicitly specify the
>> message destination JNDI:
>>
>> <message-driven>
>> <ejb-name>ServiceActivator</ejb-name>
>> <!--<mapped-name>jms/myQueue</mapped-name> -->
>>
>> <activation-config>
>> <!-- For JMS message-driven beans,
>> the following property names are recognized:
>> acknowledgeMode, messageSelector, destinationType,
>> subscriptionDurability
>> -->
>> <activation-config-property>
>>
>> <activation-config-property-name>destinationType</activation-config-pro
>> perty-name>
>>
>> <activation-config-property-value>javax.jms.Queue</activation-config-pr
>> operty-value>
>> </activation-config-property>
>> </activation-config>
>>
>> <message-destination-ref>
>> <!--<description>Reference to the Queue consumed by
>> the MDB</description> -->
>> <!-- The message-destination-ref-name element specifies
>> the name of a message destination reference;
>> its value is the message destination reference name
>> used in the component code.
>> The name is a JNDI name relative to the
>> java:comp/env context and must be unique within an component.
>> -->
>>
>> <message-destination-ref-name>jms/myQueue</message-destination-ref-name
>>
>> <message-destination-type>javax.jms.Queue</message-destination-type>
>>
>> <message-destination-usage>Consumes</message-destination-usage>
>> </message-destination-ref>
>> </message-driven>
>>
>>
>> But this alternative do not work and fail with the following message:
>>
>> [#|2011-10-21T15:31:21.844-0200|SEVERE|glassfish3.1.1|javax.enterprise.
>> system.container.ejb.mdb.com.sun.ejb.containers|_ThreadID=22;_ThreadNam
>> e=Thread-2;|MDB00017: [ServiceActivator]: Exception in creating
>> message-driven bean container:
>> [com.sun.appserv.connectors.internal.api.ConnectorRuntimeException:
>> Error in Runtime DD: missing destination JNDI name]|#]
>>
>> [#|2011-10-21T15:31:21.846-0200|SEVERE|glassfish3.1.1|javax.enterprise.
>> system.container.ejb.mdb.com.sun.ejb.containers|_ThreadID=22;_ThreadNam
>> e=Thread-2;|com.sun.appserv.connectors.internal.api.ConnectorRuntimeExc
>> eption
>> com.sun.appserv.connectors.internal.api.ConnectorRuntimeException:
>> Error in Runtime DD: missing destination JNDI name
>>
>> Is it a Glassfish bug?
>> If not, what is the correct way to explicitly set the JNDI destination
>> name? I think using activation config destinationName property may not
>> work nor be EJB 3.1 spec compliant.
>>
>> NOTE: My examples were based on section 16.9.2 from the EJB 3.1 spec. I
>> couldn't find how my example differs from the example stated in specs.
>>
>> Best regards,
>> Orair.