ActiveMQ
  1. ActiveMQ
  2. AMQ-4305

Support destination lookup by JNDI name in resource adapter

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.7.0
    • Fix Version/s: 5.9.0
    • Component/s: JCA Container
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      Use Case:

      A standalone ActiveMQ broker is integrated with a Java EE 6 server (e.g. JBoss AS 7.1, GlassFish 3.1) via activemq-rar-5.7.0.rar.

      Admin objects corresponding to queues or topics are created at server level, assigning a JNDI name in addition to the physical destination name.

      MDBs are used to handle incoming messages from ActiveMQ destinations. The destination is specified by

      @ActivationConfigProperty(propertyName = "destination", propertyValue = "physical-destination-name")

      Problem:

      The physical destination name is now hard-coded in the application. Thus, it is not possible to deploy the unchanged application in a different runtime environment where the given destination has a different physical name.

      Possible solution:

      Create a new activation config property named "destinationJndiName". If this property is set, the destination is supposed to be registered in JNDI with the name given by the property value. When this property is set, both "destinationType" and "destination" are not required.

      1. AMQ-4305.patch
        3 kB
        Harald Wellmann

        Activity

        Hide
        Mikael Falkvidd added a comment -

        Tested with activemq-rar-5.9-20130214.033724-6.rar and JBoss AS 7.2.0.Alpha1-SNAPSHOT from 2013-02-08. It connects to the right queue based on jndi name (instead of physical name) and if I configure it to connect to a non-existing jndi name it is unable to connect with the following error:
        Caused by: javax.resource.ResourceException: JNDI lookup failed for java:/queue/sms/sms-inbound/prod
        (just as expected)

        Show
        Mikael Falkvidd added a comment - Tested with activemq-rar-5.9-20130214.033724-6.rar and JBoss AS 7.2.0.Alpha1-SNAPSHOT from 2013-02-08. It connects to the right queue based on jndi name (instead of physical name) and if I configure it to connect to a non-existing jndi name it is unable to connect with the following error: Caused by: javax.resource.ResourceException: JNDI lookup failed for java:/queue/sms/sms-inbound/prod (just as expected)
        Hide
        Harald Wellmann added a comment -

        activemq-rar-5.9-SNAPSHOT against an ActiveMQ 5.7.0 server should work - that's what I used when developing the patch.

        Show
        Harald Wellmann added a comment - activemq-rar-5.9-SNAPSHOT against an ActiveMQ 5.7.0 server should work - that's what I used when developing the patch.
        Hide
        David Boman added a comment -

        When testing this - can i use activemq-rar-5.9-SNAPSHOT against an ActiveMQ 5.7.0 server or do i need to install a snapshot distribution of the server as well? (I'm working together with Mikael Falkvidd who commented above).

        Show
        David Boman added a comment - When testing this - can i use activemq-rar-5.9-SNAPSHOT against an ActiveMQ 5.7.0 server or do i need to install a snapshot distribution of the server as well? (I'm working together with Mikael Falkvidd who commented above).
        Hide
        Christian Posta added a comment -

        Please test it out on tonight's snapshot and let us know

        Show
        Christian Posta added a comment - Please test it out on tonight's snapshot and let us know
        Hide
        Christian Posta added a comment -

        Patch looks good, applied with SVN r1445642.
        Also added unit test.
        Thanks for the contribution!!

        Show
        Christian Posta added a comment - Patch looks good, applied with SVN r1445642. Also added unit test. Thanks for the contribution!!
        Hide
        Claus Ibsen added a comment -

        This looks like a good idea, lets put it on the roadmap. AMQ 5.8 is currently in VOTE and about to be released; so that is possible to late. Putting this up for the next release then.

        Show
        Claus Ibsen added a comment - This looks like a good idea, lets put it on the roadmap. AMQ 5.8 is currently in VOTE and about to be released; so that is possible to late. Putting this up for the next release then.
        Hide
        Mikael Falkvidd added a comment -

        Tested with JBoss AS 7.2.0.Alpha1-SNAPSHOT from 2013-02-08 and activemq-rar-5.7.0 with this patch applied, works like a charm.
        This enables us to configure different queues for our prod and dev machines without changing the code/annotations.

        Show
        Mikael Falkvidd added a comment - Tested with JBoss AS 7.2.0.Alpha1-SNAPSHOT from 2013-02-08 and activemq-rar-5.7.0 with this patch applied, works like a charm. This enables us to configure different queues for our prod and dev machines without changing the code/annotations.
        Hide
        Harald Wellmann added a comment -

        Attached a simple patch which introduces an additional property "useJndi". If this property is true, then the "destination" is interpreted as a JNDI name. If JNDI lookup fails, a ResourceException is thrown.

        Thus, an MDB can be configured like this:

        @MessageDriven(activationConfig =

        { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/exported/jms/demoQueue"), @ActivationConfigProperty(propertyName = "useJndi", propertyValue = "true"), }

        )

        Tested with JBoss 7.1.3.

        Show
        Harald Wellmann added a comment - Attached a simple patch which introduces an additional property "useJndi". If this property is true, then the "destination" is interpreted as a JNDI name. If JNDI lookup fails, a ResourceException is thrown. Thus, an MDB can be configured like this: @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/exported/jms/demoQueue"), @ActivationConfigProperty(propertyName = "useJndi", propertyValue = "true"), } ) Tested with JBoss 7.1.3.

          People

          • Assignee:
            Christian Posta
            Reporter:
            Harald Wellmann
          • Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development