jms-spec
  1. jms-spec
  2. JMS_SPEC-55

Define a standard way to configure the connection factory used by a JMS MDB to consume messages

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 2.0FD, 2.0
    • Labels:
      None

      Description

      This is a request for the EJB specification to define a standard way to configure the connection factory used by a MDB to consume messages.

      Currently there is no standard way to do this, and vendors differ in the way in which connection information is specified in a MDB. Some vendors support an activation property connectionFactoryJndiName but this is not defined in the EJB 3.1 (or the JCA 1.6) specifications and support for it is not universal. In fact some vendors expect connection information to be specified directly using non-standard activation properties rather than via a connection factory.

      This limits the portability of applications between different JMS providers, resource adapters and application servers. It will also hinder the automatic provisioning of JMS resources in a PaaS environment which is a goal of Java EE 7.

      Two alternatives are proposed:

      1. Define a mandatory activation property connectionFactoryJndiName

      This would make it mandatory for application servers to support the activation property connectionFactoryJndiName. This would essentially standardise what some vendors support already.

      This could be specified in ejb-jar.xml as follows:

      <ejb-jar>
        <enterprise-beans>
          <message-driven>
            <ejb-name>MyMDB</ejb-name>
            <activation-config>          
               <activation-config-property>
                  <activation-config-property-name>connectionFactoryJndiName</activation-config-property-name>
                  <activation-config-property-value>jms/connectionFactory</activation-config-property-value>
               </activation-config-property>
            <activation-config>   
            ...
      

      ...or using annotation as follows:

      @MessageDriven(
          activationConfig = {
              @ActivationConfigProperty(
                  propertyName="connectionFactoryJndiName", propertyValue="jms/connectionFactory")
          })
      public class MyMDB implements MessageListener {
      ....
      

      2. Define a new element under the <message-driven> element and a corresponding annotation

      This option would propose that the <message-driven> element in ejb-jar.xml be extended to define an addition sub-element which can be used to specify the JNDI name of the connection factory used by a JMS message-driven bean to consume messages. A suggested element name is <connection-factory-jndi-name>:

      <ejb-jar>
        <enterprise-beans>
          <message-driven>
            <ejb-name>MessageBean</ejb-name>
            <message-destination-type>javax.jms.Queue</message-destination-type>
            <connection-factory-jndi-name>jms/connectionFactory<connection-factory-jndi-name>
            ...
      

      To provide an equivalent annotation, a new attribute would need to be added to the @MessageDriven annotation. A suggested name is connectionFactoryJndiName:

      @MessageDriven(connectionFactoryJndiName="jms/connectionFactory")
      public class MyMDB implements MessageListener {
      ....
      

      It might be asked why this needs to be defined by a new subelement of <message-driven> and a new attribute of @MessageDriven rather than by a new standard activation configuration property. Possible answers are:

      • this is needed for consistency with the existing <message-destination-link> and the proposed <message-destination-jndi-name> subelements of <message-driven>. (See JMS_SPEC-54).
      • the connection factory is such an important property of a JMS MDB that it deserves explicit support in the ejb-jar.xml schema and by the compiler, rather than being relegated to being just an activation property.

      Options

      In brief, the options are:

      1) New mandatory activation property connectionFactoryJndiName
      2) New element <connection-factory-jndi-name> and corresponding annotation @MessageDriven(connectionFactoryJndiName=...
      3) Both 1) and 2)
      4) Neither

        Issue Links

          Activity

          Hide
          Nigel Deakin added a comment -

          The current proposal is to define a standard activation property connectionFactoryLookup.

          However this is only possible if the connector spec can guarantee that the resource adapter will be able to perform the lookup in the endpointActivation call. I have logged CONNECTOR_SPEC-4 to request clarification .

          Show
          Nigel Deakin added a comment - The current proposal is to define a standard activation property connectionFactoryLookup . However this is only possible if the connector spec can guarantee that the resource adapter will be able to perform the lookup in the endpointActivation call. I have logged CONNECTOR_SPEC-4 to request clarification .
          Hide
          Nigel Deakin added a comment -

          The JMS 2.0 and EJB 3.2 specifications now define a activation property connectionFactoryLookup. This is defined as follows (JMS 2.0 section 13.1 "MDB activation properties"):

          Activation property Description
          connectionFactoryLookup This property may be used to specify the lookup name of an administratively-defined javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory or javax.jms.TopicConnectionFactory object that will be used to connect to the JMS provider from which the endpoint (message-driven bean) is to receive messages.

          This issue is now incorporated in the JMS 2.0 spec and can be marked as resolved.

          Show
          Nigel Deakin added a comment - The JMS 2.0 and EJB 3.2 specifications now define a activation property connectionFactoryLookup . This is defined as follows (JMS 2.0 section 13.1 "MDB activation properties"): Activation property Description connectionFactoryLookup This property may be used to specify the lookup name of an administratively-defined javax.jms.ConnectionFactory , javax.jms.QueueConnectionFactory or javax.jms.TopicConnectionFactory object that will be used to connect to the JMS provider from which the endpoint (message-driven bean) is to receive messages. This issue is now incorporated in the JMS 2.0 spec and can be marked as resolved.

            People

            • Assignee:
              Nigel Deakin
              Reporter:
              Nigel Deakin
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: