I'm returning to this issue which we discussed back in July. This was about improving the EJB specification to define
more explicitly how a MDB that used JMS should be configured.
This issue is being tracked using the following JIRA issue
http://java.net/jira/browse/JMS_SPEC-30
Here's what I originally wrote in the JIRA issue:
----------------------------------------------------------------------------------------------------------------------
The EJB 3.1 spec is distinctly vague about how a MDB is defined. The relevant sections are 5.4.15, 5.4.16 and 5.4.17.1.
The only activation config properties defined are acknowledgeMode (only used when transactions are bean-managed, and
which must be either Auto-acknowledge or Dups-ok-acknowledge), messageSelector, destinationType (which must be must be
either javax.jms.Queue or javax.jms.Topic) and subscriptionDurability (which must be either Durable or NonDurable). But
it doesn't specify how the destination is defined or, when subscriptionDurability is Durable, how the subscription name
and client identifier are defined.
The JCA 1.6 spec has some additional guidance, at least for MDBs that use a resource adapter. Section B2 states that
providers are "strongly encouraged" to provide the properties mentioned above and also destination, subscriptionName and
clientId, with destination and destinationType as "required" properties.
Whatever else we do, there seems to be a clear need to make these mandatory for JMS MDBs, whether or not they use JCA.
----------------------------------------------------------------------------------------------------------------------
Following the discussion we had at the time, and the discussions I had with the EJB 3.2 spec lead, I would like to make
some more specific proposals about clientId and subscriptionName. (I've also added this text to the JIRA issue, you may
find that earier to read):
I propose that we seek a change to the EJB 3.2 spec to add additional activation configuration properties "clientId" and
"subscriptionName" for JMS message-driven beans
Section 5.4 of the EJB 3.1 spec currently defines the the following activation configuration properties for JMS
message-driven beans:
acknowledgeMode (optional, default is AUTO_ACKNOWLEDGE)
messageSelector (default is an empty String)
destinationType (optional, no default)
subscriptionDurability (default is NonDurable)
This should be extended to define the following additional activation configuration properties:
clientId
subscriptionName
These property names match those recommended in JCA 1.6.
If set, clientId would be used to set clientId for the connection used by the MDB, and must be unique in accordance with
JMS 1.1. There would be no default value. JMS 1.1 states that clientId must be set if a durable subscription is being
used. However in JMS 2.0 (JMS_SPEC-39) this requirement would be removed and clientId would always be optional.
If a durable subscription is being used, then JMS requires that subscriptionName be set. In the case of a MDB the
subscriptionName is normally given a name unique to the MDB, to distinguish it from other MDBs and other applications
subscribed to the same topic. It is therefore proposed that the EJB specification state that if the subscription is
durable and subscriptionName is not set then the container will automatically set subscriptionName to the name of the MDB.
As with the existing activation configuration properties for JMS message-driven beans defined in the EJB specification,
clientId and subscriptionName could be specified either using the MessageDriven annotation
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "subscriptionDurability.", propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue = "MyMDB"),
@ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "MySub")
})
or in ejb-jar.xml
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>test.MyMDB</ejb-name>
<activation-config>
<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>clientId</activation-config-property-name>
<activation-config-property-value>MyMDB</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>subscriptionName</activation-config-property-name>
<activation-config-property-value>MySub</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>
Note: The issue of how to define the destination on which a JMS message-driven bean listens for messages will be
considered separately, as this is a more complex topic. I'll be raising this separately.
------------------------------------------------------------------------------------------------------------------------
As before, please let me know what you think. I'd like to establish agreement on this before raising if formally with
the EJB EG.
Nigel