Rüdiger,
I'm glad someone's paying attention! You're right of course. I intend these to be attributes of the annotation, so they
need to be camel-case rather than hyphenated. I've corrected them. As I said, the EJB EG may change the names, but I
want to propose names that would work in principle.
Nigel
On 25/10/2011 11:43, Rüdiger zu Dohna wrote:
> Then, e.g., message-destination-link would have to be renamed to messageDestinationLink, if you don't want to resort
> to the currently usual way to configure an MDB with activation config properties:
>
> @MessageDriven(activationConfig = {_at_ActivationConfigProperty(propertyName="message-destination-link",
> propertyValue="ExpenseProcessingQueue")})
>
> On 25.10.2011, at 12:19, Nigel Deakin wrote:
>
>> I'd describe these as examples rather than as psuedo-code. They're intended to be valid java.
>>
>> But I did forget the "@" from the annotations which I've now fixed.
>>
>> The EJB expect group may wish to change the actual attribute names, but I think the names I propose would be fine.
>>
>> Nigel
>>
>> On 25/10/2011 09:22, Rüdiger zu Dohna wrote:
>>> +1
>>>
>>> Maybe it should be noted that the examples in proposal B and C are just pseudo code to make it more readable.
>>>
>>>
>>> On 21.10.2011, at 20:05, Nigel Deakin wrote:
>>>
>>>> I have logged the following JIRA issue
>>>> http://java.net/jira/browse/JMS_SPEC-54
>>>>
>>>> This is a companion issue to http://java.net/jira/browse/JMS_SPEC-30 (Define mandatory activation config properties for
>>>> JMS MDBs) which covers standardising how you can configure the queue or topic on which a MDB consumes messages.
>>>>
>>>> This isn't actually a JMS issue, it's a MDB issue, and I've already reviewed this in principle with the Java EE and EJB
>>>> spec leads, but I'd like to run this past the JMS expert group before submitting this as a formal request to the EJB
>>>> expert group.
>>>>
>>>> The issue description is below, but it may be easier to read the formatted version using the JIRA link above.
>>>>
>>>> This proposal suggests some new XML element and annotation attribute names: I expect these will be subject to change.
>>>>
>>>> As always, comments welcome (including those of the +1 variety...). Does anyone think I've missed anything?
>>>>
>>>> Nigel
>>>>
>>>>
>>>> Define a standard way to configure the destination on which a MDB consumes messages
>>>> -----------------------------------------------------------------------------------
>>>>
>>>> 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 {{_at_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 {{_at_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 {{_at_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 {{_at_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 {{_at_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 message is automatically generated by JIRA.
>>>> -
>>>> If you think it was sent incorrectly contact one of the administrators: http://java.net/jira/secure/Administrators.jspa
>>>> -
>>>> For more information on JIRA, see: http://www.atlassian.com/software/jira
>>>>
>>>>
>>>
>