Issue Details (XML | Word | Printable)

Key: JMS_SPEC-54
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Nigel Deakin
Reporter: Nigel Deakin
Votes: 1
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
jms-spec

Define a standard way to configure the destination on which a JMS MDB consumes messages

Created: 21/Oct/11 05:13 PM   Updated: 20/Mar/13 03:47 PM   Resolved: 07/Feb/13 06:54 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0FD, 2.0

Time Tracking:
Not Specified

Issue Links:
Dependency
Related
 

Tags: eg jms20-jsr345 pd20-added
Participants: Nigel Deakin and rdohna


 Description  « Hide

This is a request for the JMS and/or EJB specifications to improve the way in which specify how an application or deployer may specify the destination from which a JMS message-driven bean to receive messages. There are several significant omissions from the specification which need to be rectified.

Although MDBs are specified in the EJB specification, this request should be considered first by the JMS 2.0 expert group who may then want to raise it with the EJB 3.2 expert group.

Review of existing specification (EJB 3.1)

In the EJB 3.1 specification, Section 16.9 "Message Destination References" states that the destination used by a JMS message-driven bean can be specified using the <message-destination-link> element of the <message-driven> element in ejb-jar.xml:

<message-driven>
   <ejb-name>ExpenseProcessing</ejb-name>
   <ejb-class>com.wombat.empl.ExpenseProcessingBean</ejb-class>
   <messaging-type>javax.jms.MessageListener</messaging-type>
   ...
   <message-destination-type>javax.jms.Queue</message-destination-type>
   <message-destination-link>ExpenseProcessingQueue</message-destination-link>
   ...
</message-driven>

Issues with the existing specification

This raises the following questions:

1. What is <message-destination-link>?

The <message-destination-link> element defines the destination from which the MDB consumes messages in terms of a "message destination reference".

The purpose of "message destination references" is to allow an application which sends messages to a particular destination and also consumes from the same destination to inform the deployer of this fact without having to actually specify the name (or JNDI name) of the destination.

As stated above, a MDB can specify the "message destination reference" of the destination from which it consumes messages using a <message-destination-link> element under the <message-driven> element. Another component (e.g. a session bean or another MDB) can specify the destination to which it sends messages using a <message-destination-link> element under a <message-destination-ref> element. If these two elements contain the same string then the deployer knows they refer to the same queue or topic.

A message destination reference is not the JNDI name of the queue or topic. It is just a logical name. It can be mapped to an actual JNDI name using the <assembly-descriptor> element in ejb-jar.xml as follows:

Here's how ejb-jar.xml could be used to define a MDB as consuming messages from a "message destination reference" called MsgBeanInQueue which was mapped to a JNDI name jms/inboundQueue:

<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-link>MsgBeanInQueue</message-destination-link>
    </message-driven>
  </enterprise-beans>
  <assembly-descriptor>
    <message-destination>
      <lookup-name>jms/inboundQueue</lookup-name>   <!---
      <message-destination-name>MsgBeanInQueue</message-destination-name>
    </message-destination>
  </assembly-descriptor>
</ejb-jar> 

A message destination reference can typically also be mapped to an actual JNDI name using the application-server-specific deployment descriptor, though by definition this is beyond the scope of the EJB specification.

2. Is that the only way you can define the destination on which a MDB consumes messages in ejb-jar.xml? Can you define its JNDI name directly without bothering with references?

No, the EJB specification doesn't mention any way to define the destination in ejb-jar.xml apart from using the <message-destination-link> element of ejb-jar.xml. In particular it doesn't define any way to define its JNDI name directly, analogous to using either the JNDI API or a @Resource(lookup="jms/foo") declaration for managed connections.

3. Can I define the message destination reference for a MDB using annotation?

No, there is equivalent to <message-destination-link> using annotation.

4. Can I define the JNDI name of the destination on which a MDB consumes messages directly using annotation?

No, there is no way to define this using annotation, analogous to using a @Resource(lookup="jms/foo") declaration when using the JMS API directly.

So, what seems to be missing?

A. As explained in (2) and (4) above, there isn't a standard way for MDB applications to short-circuit the use of message destination references and define the JNDI name of the destination from which a JMS message-driven bean consumes messages, either using ejb-jar.xml or annotations. This contrasts with EJBs which send messages, where the JNDI name of the destination can be specified in the MDB code using the JNDI API or a @Resource(lookup="jms/foo") declaration.

B. As explained in (3) above, there is no standard way for the application to define using annotation the "message destination reference" on which the JMS message-driven bean is consuming messages.

Proposals:

A. It is proposed that the <message-driven> element in ejb-jar.xml be extended to define an additional sub-element which can be used to specify the JNDI name of the destination from which a JMS message-driven mean consumes messages. A suggested element name is <message-destination-jndi-name>:

<ejb-jar>
  <display-name>Ejb1</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-jndi-name>jms/inboundQueue<message-destination-jndi-name>
      ...

It might be asked why this needs to be defined by a new subelement of <message-driven> rather than, say, a new standard activation configuration property. The answer is that the way that the JNDI name is defined needs to be consistent with the way that the message destination reference is defined, which is by the <message-destination-link> subelement of <message-driven>

B. It is proposed that the equivalent annotation be a new attribute of the @MessageDriven annotation, called messageDestinationJndiName. For example:

@MessageDriven(messageDestinationJndiName="jms/inboundQueue")
public class MyMDB implements MessageListener {
....

C. It is proposed that the @MessageDriven annotation be extended to allow applications to define the "message destination reference" on which the JMS message-driven bean is consuming messages, using a new attribute messageDestinationLink"

@MessageDriven(messageDestinationLink="ExpenseProcessingQueue")
public class MyMDB implements MessageListener {
....


Sort Order: Ascending order - Click to sort in descending order
Nigel Deakin made changes - 25/Oct/11 10:11 AM
Field Original Value New Value
Description This is a request for the JMS and/or EJB specifications to improve the way in which specify how an application or deployer may specify the destination from which a JMS message-driven bean to receive messages. There are several significant omissions from the specification which need to be rectified.

Although MDBs are specified in the EJB specification, this request should be considered first by the JMS 2.0 expert group who may then want to raise it with the EJB 3.2 expert group.

h3. Review of existing specification (EJB 3.1)

In the EJB 3.1 specification, Section 16.9 "Message Destination References" states that the destination used by a JMS message-driven bean can be specified using the {{<message-destination-link>}} element of the <message-driven> element in {{ejb-jar.xml}}:

{noformat}
<message-driven>
   <ejb-name>ExpenseProcessing</ejb-name>
   <ejb-class>com.wombat.empl.ExpenseProcessingBean</ejb-class>
   <messaging-type>javax.jms.MessageListener</messaging-type>
   ...
   <message-destination-type>javax.jms.Queue</message-destination-type>
   <message-destination-link>ExpenseProcessingQueue</message-destination-link>
   ...
</message-driven>
{noformat}

h3. Issues with the existing specification

This raises the following questions:

h4. 1. What is <message-destination-link>?

The {{<message-destination-link>}} element defines the destination from which the MDB consumes messages in terms of a "message destination reference".

The purpose of "message destination references" is to allow an application which sends messages to a particular destination and also consumes from the same destination to inform the deployer of this fact without having to actually specify the name (or JNDI name) of the destination.

As stated above, a MDB can specify the "message destination reference" of the destination from which it consumes messages using a {{<message-destination-link>}} element under the <message-driven> element. Another component (e.g. a session bean or another MDB) can specify the destination to which it sends messages using a {{<message-destination-link>}} element under a {{<message-destination-ref>}} element. If these two elements contain the same string then the deployer knows they refer to the same queue or topic.

A message destination reference is not the JNDI name of the queue or topic. It is just a logical name. It can be mapped to an actual JNDI name using the {{<assembly-descriptor>}} element in {{ejb-jar.xml}} as follows:

Here's how {{ejb-jar.xml}} could be used to define a MDB as consuming messages from a "message destination reference" called {{MsgBeanInQueue}} which was mapped to a JNDI name {{jms/inboundQueue}}:

{noformat}
<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-link>MsgBeanInQueue</message-destination-link>
    </message-driven>
  </enterprise-beans>
  <assembly-descriptor>
    <message-destination>
      <lookup-name>jms/inboundQueue</lookup-name> <!---
      <message-destination-name>MsgBeanInQueue</message-destination-name>
    </message-destination>
  </assembly-descriptor>
</ejb-jar>
{noformat}

A message destination reference can typically also be mapped to an actual JNDI name using the application-server-specific deployment descriptor, though by definition this is beyond the scope of the EJB specification.

h4. 2. Is that the only way you can define the destination on which a MDB consumes messages in ejb-jar.xml? Can you define its JNDI name directly without bothering with references?

No, the EJB specification doesn't mention any way to define the destination in {{ejb-jar.xml}} apart from using the {{<message-destination-link>}} element of {{ejb-jar.xml}}. In particular it doesn't define any way to define its JNDI name directly, analogous to using either the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration for managed connections.

h4. 3. Can I define the message destination reference for a MDB using annotation?

No, there is equivalent to {{<message-destination-link>}} using annotation.

h4. 4. Can I define the JNDI name of the destination on which a MDB consumes messages directly using annotation?

No, there is no way to define this using annotation, analogous to using a {{@Resource(lookup="jms/foo")}} declaration when using the JMS API directly.

So, what seems to be missing?

A. As explained in (2) and (4) above, there isn't a standard way for MDB applications to short-circuit the use of message destination references and define the JNDI name of the destination from which a JMS message-driven bean consumes messages, either using {{ejb-jar.xml}} or annotations. This contrasts with EJBs which send messages, where the JNDI name of the destination can be specified in the MDB code using the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration.

B. As explained in (3) above, there is no standard way for the application to define using annotation the "message destination reference" on which the JMS message-driven bean is consuming messages.

h3. Proposals:

A. *It is proposed* that the {{<message-driven>}} element in {{ejb-jar.xml}} be extended to define an additional sub-element which can be used to specify the JNDI name of the destination from which a JMS message-driven mean consumes messages. A suggested element name is {{<message-destination-jndi-name>}}:

{noformat}
<ejb-jar>
  <display-name>Ejb1</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-jndi-name>jms/inboundQueue<message-destination-jndi-name>
      ...

{noformat}

It might be asked why this needs to be defined by a new subelement of {{<message-driven>}} rather than, say, a new standard activation configuration property. The answer is that the way that the JNDI name is defined needs to be consistent with the way that the message destination reference is defined, which is by the {{<message-destination-link>}} subelement of {{<message-driven>}}

B. *It is proposed* that the equivalent annotation be a new attribute of the {{@MessageDriven}} annotation, called {{message-destination-jndi-name}}. For example:

{noformat}
MessageDriven(message-destination-jndi-name="jms/inboundQueue")
public class MyMDB implements MessageListener {
....
{noformat}

C. *It is proposed* that the {{@MessageDriven}} annotation be extended to allow applications to define the "message destination reference" on which the JMS message-driven bean is consuming messages, using a new attribute {{message-destination-link"}}

{noformat}
MessageDriven(message-destination-link="ExpenseProcessingQueue")
public class MyMDB implements MessageListener {
....
{noformat}
This is a request for the JMS and/or EJB specifications to improve the way in which specify how an application or deployer may specify the destination from which a JMS message-driven bean to receive messages. There are several significant omissions from the specification which need to be rectified.

Although MDBs are specified in the EJB specification, this request should be considered first by the JMS 2.0 expert group who may then want to raise it with the EJB 3.2 expert group.

h3. Review of existing specification (EJB 3.1)

In the EJB 3.1 specification, Section 16.9 "Message Destination References" states that the destination used by a JMS message-driven bean can be specified using the {{<message-destination-link>}} element of the <message-driven> element in {{ejb-jar.xml}}:

{noformat}
<message-driven>
   <ejb-name>ExpenseProcessing</ejb-name>
   <ejb-class>com.wombat.empl.ExpenseProcessingBean</ejb-class>
   <messaging-type>javax.jms.MessageListener</messaging-type>
   ...
   <message-destination-type>javax.jms.Queue</message-destination-type>
   <message-destination-link>ExpenseProcessingQueue</message-destination-link>
   ...
</message-driven>
{noformat}

h3. Issues with the existing specification

This raises the following questions:

h4. 1. What is <message-destination-link>?

The {{<message-destination-link>}} element defines the destination from which the MDB consumes messages in terms of a "message destination reference".

The purpose of "message destination references" is to allow an application which sends messages to a particular destination and also consumes from the same destination to inform the deployer of this fact without having to actually specify the name (or JNDI name) of the destination.

As stated above, a MDB can specify the "message destination reference" of the destination from which it consumes messages using a {{<message-destination-link>}} element under the <message-driven> element. Another component (e.g. a session bean or another MDB) can specify the destination to which it sends messages using a {{<message-destination-link>}} element under a {{<message-destination-ref>}} element. If these two elements contain the same string then the deployer knows they refer to the same queue or topic.

A message destination reference is not the JNDI name of the queue or topic. It is just a logical name. It can be mapped to an actual JNDI name using the {{<assembly-descriptor>}} element in {{ejb-jar.xml}} as follows:

Here's how {{ejb-jar.xml}} could be used to define a MDB as consuming messages from a "message destination reference" called {{MsgBeanInQueue}} which was mapped to a JNDI name {{jms/inboundQueue}}:

{noformat}
<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-link>MsgBeanInQueue</message-destination-link>
    </message-driven>
  </enterprise-beans>
  <assembly-descriptor>
    <message-destination>
      <lookup-name>jms/inboundQueue</lookup-name> <!---
      <message-destination-name>MsgBeanInQueue</message-destination-name>
    </message-destination>
  </assembly-descriptor>
</ejb-jar>
{noformat}

A message destination reference can typically also be mapped to an actual JNDI name using the application-server-specific deployment descriptor, though by definition this is beyond the scope of the EJB specification.

h4. 2. Is that the only way you can define the destination on which a MDB consumes messages in ejb-jar.xml? Can you define its JNDI name directly without bothering with references?

No, the EJB specification doesn't mention any way to define the destination in {{ejb-jar.xml}} apart from using the {{<message-destination-link>}} element of {{ejb-jar.xml}}. In particular it doesn't define any way to define its JNDI name directly, analogous to using either the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration for managed connections.

h4. 3. Can I define the message destination reference for a MDB using annotation?

No, there is equivalent to {{<message-destination-link>}} using annotation.

h4. 4. Can I define the JNDI name of the destination on which a MDB consumes messages directly using annotation?

No, there is no way to define this using annotation, analogous to using a {{@Resource(lookup="jms/foo")}} declaration when using the JMS API directly.

So, what seems to be missing?

A. As explained in (2) and (4) above, there isn't a standard way for MDB applications to short-circuit the use of message destination references and define the JNDI name of the destination from which a JMS message-driven bean consumes messages, either using {{ejb-jar.xml}} or annotations. This contrasts with EJBs which send messages, where the JNDI name of the destination can be specified in the MDB code using the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration.

B. As explained in (3) above, there is no standard way for the application to define using annotation the "message destination reference" on which the JMS message-driven bean is consuming messages.

h3. Proposals:

A. *It is proposed* that the {{<message-driven>}} element in {{ejb-jar.xml}} be extended to define an additional sub-element which can be used to specify the JNDI name of the destination from which a JMS message-driven mean consumes messages. A suggested element name is {{<message-destination-jndi-name>}}:

{noformat}
<ejb-jar>
  <display-name>Ejb1</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-jndi-name>jms/inboundQueue<message-destination-jndi-name>
      ...

{noformat}

It might be asked why this needs to be defined by a new subelement of {{<message-driven>}} rather than, say, a new standard activation configuration property. The answer is that the way that the JNDI name is defined needs to be consistent with the way that the message destination reference is defined, which is by the {{<message-destination-link>}} subelement of {{<message-driven>}}

B. *It is proposed* that the equivalent annotation be a new attribute of the {{@MessageDriven}} annotation, called {{message-destination-jndi-name}}. For example:

{noformat}
@MessageDriven(message-destination-jndi-name="jms/inboundQueue")
public class MyMDB implements MessageListener {
....
{noformat}

C. *It is proposed* that the {{@MessageDriven}} annotation be extended to allow applications to define the "message destination reference" on which the JMS message-driven bean is consuming messages, using a new attribute {{message-destination-link"}}

{noformat}
@MessageDriven(message-destination-link="ExpenseProcessingQueue")
public class MyMDB implements MessageListener {
....
{noformat}
rdohna made changes - 25/Oct/11 10:38 AM
Link This issue is related to JMS_SPEC-30 [ JMS_SPEC-30 ]
Nigel Deakin made changes - 25/Oct/11 11:17 AM
Description This is a request for the JMS and/or EJB specifications to improve the way in which specify how an application or deployer may specify the destination from which a JMS message-driven bean to receive messages. There are several significant omissions from the specification which need to be rectified.

Although MDBs are specified in the EJB specification, this request should be considered first by the JMS 2.0 expert group who may then want to raise it with the EJB 3.2 expert group.

h3. Review of existing specification (EJB 3.1)

In the EJB 3.1 specification, Section 16.9 "Message Destination References" states that the destination used by a JMS message-driven bean can be specified using the {{<message-destination-link>}} element of the <message-driven> element in {{ejb-jar.xml}}:

{noformat}
<message-driven>
   <ejb-name>ExpenseProcessing</ejb-name>
   <ejb-class>com.wombat.empl.ExpenseProcessingBean</ejb-class>
   <messaging-type>javax.jms.MessageListener</messaging-type>
   ...
   <message-destination-type>javax.jms.Queue</message-destination-type>
   <message-destination-link>ExpenseProcessingQueue</message-destination-link>
   ...
</message-driven>
{noformat}

h3. Issues with the existing specification

This raises the following questions:

h4. 1. What is <message-destination-link>?

The {{<message-destination-link>}} element defines the destination from which the MDB consumes messages in terms of a "message destination reference".

The purpose of "message destination references" is to allow an application which sends messages to a particular destination and also consumes from the same destination to inform the deployer of this fact without having to actually specify the name (or JNDI name) of the destination.

As stated above, a MDB can specify the "message destination reference" of the destination from which it consumes messages using a {{<message-destination-link>}} element under the <message-driven> element. Another component (e.g. a session bean or another MDB) can specify the destination to which it sends messages using a {{<message-destination-link>}} element under a {{<message-destination-ref>}} element. If these two elements contain the same string then the deployer knows they refer to the same queue or topic.

A message destination reference is not the JNDI name of the queue or topic. It is just a logical name. It can be mapped to an actual JNDI name using the {{<assembly-descriptor>}} element in {{ejb-jar.xml}} as follows:

Here's how {{ejb-jar.xml}} could be used to define a MDB as consuming messages from a "message destination reference" called {{MsgBeanInQueue}} which was mapped to a JNDI name {{jms/inboundQueue}}:

{noformat}
<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-link>MsgBeanInQueue</message-destination-link>
    </message-driven>
  </enterprise-beans>
  <assembly-descriptor>
    <message-destination>
      <lookup-name>jms/inboundQueue</lookup-name> <!---
      <message-destination-name>MsgBeanInQueue</message-destination-name>
    </message-destination>
  </assembly-descriptor>
</ejb-jar>
{noformat}

A message destination reference can typically also be mapped to an actual JNDI name using the application-server-specific deployment descriptor, though by definition this is beyond the scope of the EJB specification.

h4. 2. Is that the only way you can define the destination on which a MDB consumes messages in ejb-jar.xml? Can you define its JNDI name directly without bothering with references?

No, the EJB specification doesn't mention any way to define the destination in {{ejb-jar.xml}} apart from using the {{<message-destination-link>}} element of {{ejb-jar.xml}}. In particular it doesn't define any way to define its JNDI name directly, analogous to using either the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration for managed connections.

h4. 3. Can I define the message destination reference for a MDB using annotation?

No, there is equivalent to {{<message-destination-link>}} using annotation.

h4. 4. Can I define the JNDI name of the destination on which a MDB consumes messages directly using annotation?

No, there is no way to define this using annotation, analogous to using a {{@Resource(lookup="jms/foo")}} declaration when using the JMS API directly.

So, what seems to be missing?

A. As explained in (2) and (4) above, there isn't a standard way for MDB applications to short-circuit the use of message destination references and define the JNDI name of the destination from which a JMS message-driven bean consumes messages, either using {{ejb-jar.xml}} or annotations. This contrasts with EJBs which send messages, where the JNDI name of the destination can be specified in the MDB code using the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration.

B. As explained in (3) above, there is no standard way for the application to define using annotation the "message destination reference" on which the JMS message-driven bean is consuming messages.

h3. Proposals:

A. *It is proposed* that the {{<message-driven>}} element in {{ejb-jar.xml}} be extended to define an additional sub-element which can be used to specify the JNDI name of the destination from which a JMS message-driven mean consumes messages. A suggested element name is {{<message-destination-jndi-name>}}:

{noformat}
<ejb-jar>
  <display-name>Ejb1</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-jndi-name>jms/inboundQueue<message-destination-jndi-name>
      ...

{noformat}

It might be asked why this needs to be defined by a new subelement of {{<message-driven>}} rather than, say, a new standard activation configuration property. The answer is that the way that the JNDI name is defined needs to be consistent with the way that the message destination reference is defined, which is by the {{<message-destination-link>}} subelement of {{<message-driven>}}

B. *It is proposed* that the equivalent annotation be a new attribute of the {{@MessageDriven}} annotation, called {{message-destination-jndi-name}}. For example:

{noformat}
@MessageDriven(message-destination-jndi-name="jms/inboundQueue")
public class MyMDB implements MessageListener {
....
{noformat}

C. *It is proposed* that the {{@MessageDriven}} annotation be extended to allow applications to define the "message destination reference" on which the JMS message-driven bean is consuming messages, using a new attribute {{message-destination-link"}}

{noformat}
@MessageDriven(message-destination-link="ExpenseProcessingQueue")
public class MyMDB implements MessageListener {
....
{noformat}
This is a request for the JMS and/or EJB specifications to improve the way in which specify how an application or deployer may specify the destination from which a JMS message-driven bean to receive messages. There are several significant omissions from the specification which need to be rectified.

Although MDBs are specified in the EJB specification, this request should be considered first by the JMS 2.0 expert group who may then want to raise it with the EJB 3.2 expert group.

h3. Review of existing specification (EJB 3.1)

In the EJB 3.1 specification, Section 16.9 "Message Destination References" states that the destination used by a JMS message-driven bean can be specified using the {{<message-destination-link>}} element of the <message-driven> element in {{ejb-jar.xml}}:

{noformat}
<message-driven>
   <ejb-name>ExpenseProcessing</ejb-name>
   <ejb-class>com.wombat.empl.ExpenseProcessingBean</ejb-class>
   <messaging-type>javax.jms.MessageListener</messaging-type>
   ...
   <message-destination-type>javax.jms.Queue</message-destination-type>
   <message-destination-link>ExpenseProcessingQueue</message-destination-link>
   ...
</message-driven>
{noformat}

h3. Issues with the existing specification

This raises the following questions:

h4. 1. What is <message-destination-link>?

The {{<message-destination-link>}} element defines the destination from which the MDB consumes messages in terms of a "message destination reference".

The purpose of "message destination references" is to allow an application which sends messages to a particular destination and also consumes from the same destination to inform the deployer of this fact without having to actually specify the name (or JNDI name) of the destination.

As stated above, a MDB can specify the "message destination reference" of the destination from which it consumes messages using a {{<message-destination-link>}} element under the <message-driven> element. Another component (e.g. a session bean or another MDB) can specify the destination to which it sends messages using a {{<message-destination-link>}} element under a {{<message-destination-ref>}} element. If these two elements contain the same string then the deployer knows they refer to the same queue or topic.

A message destination reference is not the JNDI name of the queue or topic. It is just a logical name. It can be mapped to an actual JNDI name using the {{<assembly-descriptor>}} element in {{ejb-jar.xml}} as follows:

Here's how {{ejb-jar.xml}} could be used to define a MDB as consuming messages from a "message destination reference" called {{MsgBeanInQueue}} which was mapped to a JNDI name {{jms/inboundQueue}}:

{noformat}
<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-link>MsgBeanInQueue</message-destination-link>
    </message-driven>
  </enterprise-beans>
  <assembly-descriptor>
    <message-destination>
      <lookup-name>jms/inboundQueue</lookup-name> <!---
      <message-destination-name>MsgBeanInQueue</message-destination-name>
    </message-destination>
  </assembly-descriptor>
</ejb-jar>
{noformat}

A message destination reference can typically also be mapped to an actual JNDI name using the application-server-specific deployment descriptor, though by definition this is beyond the scope of the EJB specification.

h4. 2. Is that the only way you can define the destination on which a MDB consumes messages in ejb-jar.xml? Can you define its JNDI name directly without bothering with references?

No, the EJB specification doesn't mention any way to define the destination in {{ejb-jar.xml}} apart from using the {{<message-destination-link>}} element of {{ejb-jar.xml}}. In particular it doesn't define any way to define its JNDI name directly, analogous to using either the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration for managed connections.

h4. 3. Can I define the message destination reference for a MDB using annotation?

No, there is equivalent to {{<message-destination-link>}} using annotation.

h4. 4. Can I define the JNDI name of the destination on which a MDB consumes messages directly using annotation?

No, there is no way to define this using annotation, analogous to using a {{@Resource(lookup="jms/foo")}} declaration when using the JMS API directly.

So, what seems to be missing?

A. As explained in (2) and (4) above, there isn't a standard way for MDB applications to short-circuit the use of message destination references and define the JNDI name of the destination from which a JMS message-driven bean consumes messages, either using {{ejb-jar.xml}} or annotations. This contrasts with EJBs which send messages, where the JNDI name of the destination can be specified in the MDB code using the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration.

B. As explained in (3) above, there is no standard way for the application to define using annotation the "message destination reference" on which the JMS message-driven bean is consuming messages.

h3. Proposals:

A. *It is proposed* that the {{<message-driven>}} element in {{ejb-jar.xml}} be extended to define an additional sub-element which can be used to specify the JNDI name of the destination from which a JMS message-driven mean consumes messages. A suggested element name is {{<message-destination-jndi-name>}}:

{noformat}
<ejb-jar>
  <display-name>Ejb1</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-jndi-name>jms/inboundQueue<message-destination-jndi-name>
      ...

{noformat}

It might be asked why this needs to be defined by a new subelement of {{<message-driven>}} rather than, say, a new standard activation configuration property. The answer is that the way that the JNDI name is defined needs to be consistent with the way that the message destination reference is defined, which is by the {{<message-destination-link>}} subelement of {{<message-driven>}}

B. *It is proposed* that the equivalent annotation be a new attribute of the {{@MessageDriven}} annotation, called {{message-destination-jndi-name}}. For example:

{noformat}
@MessageDriven(messageDestinationJndiName="jms/inboundQueue")
public class MyMDB implements MessageListener {
....
{noformat}

C. *It is proposed* that the {{@MessageDriven}} annotation be extended to allow applications to define the "message destination reference" on which the JMS message-driven bean is consuming messages, using a new attribute {{messageDestinationLink"}}

{noformat}
@MessageDriven(messageDestinationLink="ExpenseProcessingQueue")
public class MyMDB implements MessageListener {
....
{noformat}
Nigel Deakin made changes - 02/Nov/11 04:35 PM
Tags eg
Nigel Deakin made changes - 07/Nov/11 10:29 AM
Tags eg eg jsr345
Nigel Deakin made changes - 07/Nov/11 01:56 PM
Summary Define a standard way to configure the destination on which a MDB consumes messages Define a standard way to configure the destination on which a JMS MDB consumes messages
Nigel Deakin made changes - 07/Nov/11 02:02 PM
Description This is a request for the JMS and/or EJB specifications to improve the way in which specify how an application or deployer may specify the destination from which a JMS message-driven bean to receive messages. There are several significant omissions from the specification which need to be rectified.

Although MDBs are specified in the EJB specification, this request should be considered first by the JMS 2.0 expert group who may then want to raise it with the EJB 3.2 expert group.

h3. Review of existing specification (EJB 3.1)

In the EJB 3.1 specification, Section 16.9 "Message Destination References" states that the destination used by a JMS message-driven bean can be specified using the {{<message-destination-link>}} element of the <message-driven> element in {{ejb-jar.xml}}:

{noformat}
<message-driven>
   <ejb-name>ExpenseProcessing</ejb-name>
   <ejb-class>com.wombat.empl.ExpenseProcessingBean</ejb-class>
   <messaging-type>javax.jms.MessageListener</messaging-type>
   ...
   <message-destination-type>javax.jms.Queue</message-destination-type>
   <message-destination-link>ExpenseProcessingQueue</message-destination-link>
   ...
</message-driven>
{noformat}

h3. Issues with the existing specification

This raises the following questions:

h4. 1. What is <message-destination-link>?

The {{<message-destination-link>}} element defines the destination from which the MDB consumes messages in terms of a "message destination reference".

The purpose of "message destination references" is to allow an application which sends messages to a particular destination and also consumes from the same destination to inform the deployer of this fact without having to actually specify the name (or JNDI name) of the destination.

As stated above, a MDB can specify the "message destination reference" of the destination from which it consumes messages using a {{<message-destination-link>}} element under the <message-driven> element. Another component (e.g. a session bean or another MDB) can specify the destination to which it sends messages using a {{<message-destination-link>}} element under a {{<message-destination-ref>}} element. If these two elements contain the same string then the deployer knows they refer to the same queue or topic.

A message destination reference is not the JNDI name of the queue or topic. It is just a logical name. It can be mapped to an actual JNDI name using the {{<assembly-descriptor>}} element in {{ejb-jar.xml}} as follows:

Here's how {{ejb-jar.xml}} could be used to define a MDB as consuming messages from a "message destination reference" called {{MsgBeanInQueue}} which was mapped to a JNDI name {{jms/inboundQueue}}:

{noformat}
<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-link>MsgBeanInQueue</message-destination-link>
    </message-driven>
  </enterprise-beans>
  <assembly-descriptor>
    <message-destination>
      <lookup-name>jms/inboundQueue</lookup-name> <!---
      <message-destination-name>MsgBeanInQueue</message-destination-name>
    </message-destination>
  </assembly-descriptor>
</ejb-jar>
{noformat}

A message destination reference can typically also be mapped to an actual JNDI name using the application-server-specific deployment descriptor, though by definition this is beyond the scope of the EJB specification.

h4. 2. Is that the only way you can define the destination on which a MDB consumes messages in ejb-jar.xml? Can you define its JNDI name directly without bothering with references?

No, the EJB specification doesn't mention any way to define the destination in {{ejb-jar.xml}} apart from using the {{<message-destination-link>}} element of {{ejb-jar.xml}}. In particular it doesn't define any way to define its JNDI name directly, analogous to using either the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration for managed connections.

h4. 3. Can I define the message destination reference for a MDB using annotation?

No, there is equivalent to {{<message-destination-link>}} using annotation.

h4. 4. Can I define the JNDI name of the destination on which a MDB consumes messages directly using annotation?

No, there is no way to define this using annotation, analogous to using a {{@Resource(lookup="jms/foo")}} declaration when using the JMS API directly.

So, what seems to be missing?

A. As explained in (2) and (4) above, there isn't a standard way for MDB applications to short-circuit the use of message destination references and define the JNDI name of the destination from which a JMS message-driven bean consumes messages, either using {{ejb-jar.xml}} or annotations. This contrasts with EJBs which send messages, where the JNDI name of the destination can be specified in the MDB code using the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration.

B. As explained in (3) above, there is no standard way for the application to define using annotation the "message destination reference" on which the JMS message-driven bean is consuming messages.

h3. Proposals:

A. *It is proposed* that the {{<message-driven>}} element in {{ejb-jar.xml}} be extended to define an additional sub-element which can be used to specify the JNDI name of the destination from which a JMS message-driven mean consumes messages. A suggested element name is {{<message-destination-jndi-name>}}:

{noformat}
<ejb-jar>
  <display-name>Ejb1</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-jndi-name>jms/inboundQueue<message-destination-jndi-name>
      ...

{noformat}

It might be asked why this needs to be defined by a new subelement of {{<message-driven>}} rather than, say, a new standard activation configuration property. The answer is that the way that the JNDI name is defined needs to be consistent with the way that the message destination reference is defined, which is by the {{<message-destination-link>}} subelement of {{<message-driven>}}

B. *It is proposed* that the equivalent annotation be a new attribute of the {{@MessageDriven}} annotation, called {{message-destination-jndi-name}}. For example:

{noformat}
@MessageDriven(messageDestinationJndiName="jms/inboundQueue")
public class MyMDB implements MessageListener {
....
{noformat}

C. *It is proposed* that the {{@MessageDriven}} annotation be extended to allow applications to define the "message destination reference" on which the JMS message-driven bean is consuming messages, using a new attribute {{messageDestinationLink"}}

{noformat}
@MessageDriven(messageDestinationLink="ExpenseProcessingQueue")
public class MyMDB implements MessageListener {
....
{noformat}
This is a request for the JMS and/or EJB specifications to improve the way in which specify how an application or deployer may specify the destination from which a JMS message-driven bean to receive messages. There are several significant omissions from the specification which need to be rectified.

Although MDBs are specified in the EJB specification, this request should be considered first by the JMS 2.0 expert group who may then want to raise it with the EJB 3.2 expert group.

h3. Review of existing specification (EJB 3.1)

In the EJB 3.1 specification, Section 16.9 "Message Destination References" states that the destination used by a JMS message-driven bean can be specified using the {{<message-destination-link>}} element of the <message-driven> element in {{ejb-jar.xml}}:

{noformat}
<message-driven>
   <ejb-name>ExpenseProcessing</ejb-name>
   <ejb-class>com.wombat.empl.ExpenseProcessingBean</ejb-class>
   <messaging-type>javax.jms.MessageListener</messaging-type>
   ...
   <message-destination-type>javax.jms.Queue</message-destination-type>
   <message-destination-link>ExpenseProcessingQueue</message-destination-link>
   ...
</message-driven>
{noformat}

h3. Issues with the existing specification

This raises the following questions:

h4. 1. What is <message-destination-link>?

The {{<message-destination-link>}} element defines the destination from which the MDB consumes messages in terms of a "message destination reference".

The purpose of "message destination references" is to allow an application which sends messages to a particular destination and also consumes from the same destination to inform the deployer of this fact without having to actually specify the name (or JNDI name) of the destination.

As stated above, a MDB can specify the "message destination reference" of the destination from which it consumes messages using a {{<message-destination-link>}} element under the <message-driven> element. Another component (e.g. a session bean or another MDB) can specify the destination to which it sends messages using a {{<message-destination-link>}} element under a {{<message-destination-ref>}} element. If these two elements contain the same string then the deployer knows they refer to the same queue or topic.

A message destination reference is not the JNDI name of the queue or topic. It is just a logical name. It can be mapped to an actual JNDI name using the {{<assembly-descriptor>}} element in {{ejb-jar.xml}} as follows:

Here's how {{ejb-jar.xml}} could be used to define a MDB as consuming messages from a "message destination reference" called {{MsgBeanInQueue}} which was mapped to a JNDI name {{jms/inboundQueue}}:

{noformat}
<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Container</transaction-type>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-link>MsgBeanInQueue</message-destination-link>
    </message-driven>
  </enterprise-beans>
  <assembly-descriptor>
    <message-destination>
      <lookup-name>jms/inboundQueue</lookup-name> <!---
      <message-destination-name>MsgBeanInQueue</message-destination-name>
    </message-destination>
  </assembly-descriptor>
</ejb-jar>
{noformat}

A message destination reference can typically also be mapped to an actual JNDI name using the application-server-specific deployment descriptor, though by definition this is beyond the scope of the EJB specification.

h4. 2. Is that the only way you can define the destination on which a MDB consumes messages in ejb-jar.xml? Can you define its JNDI name directly without bothering with references?

No, the EJB specification doesn't mention any way to define the destination in {{ejb-jar.xml}} apart from using the {{<message-destination-link>}} element of {{ejb-jar.xml}}. In particular it doesn't define any way to define its JNDI name directly, analogous to using either the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration for managed connections.

h4. 3. Can I define the message destination reference for a MDB using annotation?

No, there is equivalent to {{<message-destination-link>}} using annotation.

h4. 4. Can I define the JNDI name of the destination on which a MDB consumes messages directly using annotation?

No, there is no way to define this using annotation, analogous to using a {{@Resource(lookup="jms/foo")}} declaration when using the JMS API directly.

So, what seems to be missing?

A. As explained in (2) and (4) above, there isn't a standard way for MDB applications to short-circuit the use of message destination references and define the JNDI name of the destination from which a JMS message-driven bean consumes messages, either using {{ejb-jar.xml}} or annotations. This contrasts with EJBs which send messages, where the JNDI name of the destination can be specified in the MDB code using the JNDI API or a {{@Resource(lookup="jms/foo")}} declaration.

B. As explained in (3) above, there is no standard way for the application to define using annotation the "message destination reference" on which the JMS message-driven bean is consuming messages.

h3. Proposals:

A. *It is proposed* that the {{<message-driven>}} element in {{ejb-jar.xml}} be extended to define an additional sub-element which can be used to specify the JNDI name of the destination from which a JMS message-driven mean consumes messages. A suggested element name is {{<message-destination-jndi-name>}}:

{noformat}
<ejb-jar>
  <display-name>Ejb1</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>MDB1</display-name>
      <ejb-name>MessageBean</ejb-name>
      <message-destination-type>javax.jms.Queue</message-destination-type>
      <message-destination-jndi-name>jms/inboundQueue<message-destination-jndi-name>
      ...

{noformat}

It might be asked why this needs to be defined by a new subelement of {{<message-driven>}} rather than, say, a new standard activation configuration property. The answer is that the way that the JNDI name is defined needs to be consistent with the way that the message destination reference is defined, which is by the {{<message-destination-link>}} subelement of {{<message-driven>}}

B. *It is proposed* that the equivalent annotation be a new attribute of the {{@MessageDriven}} annotation, called {{messageDestinationJndiName}}. For example:

{noformat}
@MessageDriven(messageDestinationJndiName="jms/inboundQueue")
public class MyMDB implements MessageListener {
....
{noformat}

C. *It is proposed* that the {{@MessageDriven}} annotation be extended to allow applications to define the "message destination reference" on which the JMS message-driven bean is consuming messages, using a new attribute {{messageDestinationLink"}}

{noformat}
@MessageDriven(messageDestinationLink="ExpenseProcessingQueue")
public class MyMDB implements MessageListener {
....
{noformat}
Nigel Deakin made changes - 23/Nov/11 05:26 PM
Link This issue depends on EJB_SPEC-42 [ EJB_SPEC-42 ]
Nigel Deakin made changes - 23/Nov/11 05:49 PM
Assignee Nigel Deakin [ nigeldeakin ]
Nigel Deakin made changes - 23/Nov/11 05:49 PM
Status Open [ 1 ] In Progress [ 3 ]
Nigel Deakin made changes - 04/Feb/12 06:28 PM
Tags eg jsr345 eg
Nigel Deakin made changes - 04/Feb/12 06:28 PM
Tags eg eg jms20-jsr345
Nigel Deakin made changes - 12/Jun/12 09:42 AM
Tags eg jms20-jsr345 eg jms20-jsr345 pd20-underreview
Nigel Deakin made changes - 26/Nov/12 02:57 PM
Tags eg jms20-jsr345 pd20-underreview eg jms20-jsr345
Nigel Deakin made changes - 26/Nov/12 02:57 PM
Tags eg jms20-jsr345 eg jms20-jsr345 pd20-added
Nigel Deakin made changes - 05/Dec/12 05:32 PM
Comment [ This issue has now been forwarded to the EJB 3.2 expert group as [EJB_SPEC-42|http://java.net/jira/browse/EJB_SPEC-42]. Please make further comments there, not here. ]
Nigel Deakin made changes - 05/Dec/12 05:34 PM
Link This issue depends on CONNECTOR_SPEC-4 [ CONNECTOR_SPEC-4 ]
Nigel Deakin made changes - 05/Dec/12 05:35 PM
Link This issue is related to JMS_SPEC-55 [ JMS_SPEC-55 ]
Nigel Deakin made changes - 05/Dec/12 05:45 PM
Link This issue depends on EJB_SPEC-42 [ EJB_SPEC-42 ]
Nigel Deakin made changes - 05/Dec/12 05:49 PM
Link This issue blocks MQ-250 [ MQ-250 ]
Nigel Deakin made changes - 07/Feb/13 06:54 PM
Resolution Fixed [ 1 ]
Fix Version/s 2.0FD [ 16325 ]
Status In Progress [ 3 ] Resolved [ 5 ]
Nigel Deakin made changes - 20/Mar/13 03:47 PM
Fix Version/s 2.0 [ 14692 ]