5 Replies Latest reply on Jul 19, 2012 3:21 AM by tiian

    Websphere MQ integration with MDB on AS7/EAP6 reloaded

    akrambenaissi

      Hello all,

       

      A similar subject has been discussed at most in 2 other threads a few months ago, and since I am working on a similar subject I would like to try to make the situation the clearer possible to incitate my customer to raise tickets on the relevant vendors.

       

      So the subject is the integration of Webpshere MQ with MessageDrivenBean on JBoss AS7 / EAP6 (Beta2).

      Here is the code:

       

      @MessageDriven(name = "WebsphereMQMessageDrivenBean", mappedName = "mdb/WebsphereMQMessageDrivenBean", activationConfig = {
          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
          @ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),
          @ActivationConfigProperty(propertyName = "destination", propertyValue = "TEST_QUEUE"),
          @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "TEST_QUEUE_MANAGER"),
          @ActivationConfigProperty(propertyName = "hostName", propertyValue = "localhost"),
          @ActivationConfigProperty(propertyName = "port", propertyValue = "1416"),
          @ActivationConfigProperty(propertyName = "channel", propertyValue = "JBOSS.SVRCONN") })
      @ResourceAdapter("wmq.jmsra.rar")
      @TransactionManagement(CONTAINER)
      @Named
      public class WebsphereMQMessageDrivenBean implements MessageListener {
      

       

      Clearly, the issue is that nobody can't live with the configuration hardcoded. And even if setting this configuration in jboss-ejb3.xml (which also works perfectly), that leads to change the JAR/EAR/WAR before putting in production, which is quite dangerous.

       

      It seems that, in the past several workarounds used to exist (AOP or using placeholders in deployment desciptors) that would not work anymore with AS7. Anyway, these were workarounds, and a real solution is always better.

      As a conclusion of another thread, it seems that this is specific to the used resource adapter, which I really want to be sure.

       

      To do so, here are two tracks that I would like to explore:

      Is there a way to set the jndi name of the "destination" of an MDB ? Other vendors seem to use a property destination-jndi-name in customer descriptor to set it. Moreover, MQ also has a parameter useJNDI (default false) to change how the "destination" parameter must be interpreted. And this does not seem to have effect. According to their doc, if useJNDI is set to true, the "destination" parameter is treated as the JNDI name of the destination queue. How can we be sure that the JNDI lookup is properly performed (with the correct InitialContext)? This does not seem to be the case, because MQ still tries to use "hostName" and the other configuration parameters, which are set in the AS configuration.

       

       

      The other track is changing the default Resource Adapter for JMS: This is documented in EAP6 official doc, and it works: One can change from hornetq-ra to wmq.jmsra.rar which turns mq to the default JMS provider for MDB. And this allows to get rid of the @ResoruceAdapter annotation. But, even if a resource adapter wmq.jmsra.rar is declared and properly default configured, the JMS provider arrives unconfigured to the MDB and needs ActivationConfigProperty to work.

      Is this the expected behaviour? If yes, that would be nice if the wmq.jmsra.rar could be treated as reference accompagned with its configuration instead of the name or the rar to load.

       

      I am not sure a solution that would make everybody (or at least me) happy exists, so please treat this discussion as a feature request.

        • 1. Re: Websphere MQ integration with MDB on AS7/EAP6 reloaded
          jaikiran

          Akram Ben Aissi wrote:

           

           

           

          It seems that, in the past several workarounds used to exist (AOP or using placeholders in deployment desciptors) that would not work anymore with AS7.

          By placeholder, if you mean system property replacement like "${foo.bar}" then that feature is available in the latest AS7 upstream https://issues.jboss.org/browse/AS7-3816.

           

           

          Akram Ben Aissi wrote:

           

          Hello all,

           

          A similar subject has been discussed at most in 2 other threads a few months ago, and since I am working on a similar subject I would like to try to make the situation the clearer possible to incitate my customer to raise tickets on the relevant vendors.

           

          So the subject is the integration of Webpshere MQ with MessageDrivenBean on JBoss AS7 / EAP6 (Beta2).

          Here is the code:

           

          @MessageDriven(name = "WebsphereMQMessageDrivenBean", mappedName = "mdb/WebsphereMQMessageDrivenBean", activationConfig = {
              @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
              @ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),
              @ActivationConfigProperty(propertyName = "destination", propertyValue = "TEST_QUEUE"),
              @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "TEST_QUEUE_MANAGER"),
              @ActivationConfigProperty(propertyName = "hostName", propertyValue = "localhost"),
              @ActivationConfigProperty(propertyName = "port", propertyValue = "1416"),
              @ActivationConfigProperty(propertyName = "channel", propertyValue = "JBOSS.SVRCONN") })
          @ResourceAdapter("wmq.jmsra.rar")
          @TransactionManagement(CONTAINER)
          @Named
          public class WebsphereMQMessageDrivenBean implements MessageListener {
          

           

          Clearly, the issue is that nobody can't live with the configuration hardcoded. And even if setting this configuration in jboss-ejb3.xml (which also works perfectly), that leads to change the JAR/EAR/WAR before putting in production, which is quite dangerous.

           

          So to summarize, what you and others are looking for is a way to somehow pass along these activation config properties such that you don't have to change the code (annotation values) and/or edit the ejb-jar.xml/jboss-ejb3.xml deployment descriptors (which requires application repackaging). Is that right? If so, then let me explain how this used to work in previous versions of JBoss AS:

           

          - Previous versions of JBoss AS used AOP to configure most part of the EJB container

          - In previous versions, we had a JBoss specific annotation called @org.jboss.ejb3.annotation.DefaultActivationSpecs which could be used as the default activation specs for a specific MDB. Here's an example http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/docs/tutorial/mdb/META-INF/custom-ejb3-interceptors-aop.xml

          - Now the individual MDB still had to point to this custom configuration either via annotation or via jboss.xml (that's the equivalent of jboss-ejb3.xml in AS7) and that was done like this http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/bean/DefaultedExampleMDB.java (look for @AspectDomain there which points to the custom configuration name).

          - So ultimately, you could have an MDB (see that DefaultedExampleMDB in the previous link) without any @ActivationConfigProperties and let the default be picked up from the custom configuration.

           

          This way the application just had to configure the custom configuration for @org.jboss.ejb3.annotation.DefaultActivationSpecs and this was allowed to be done externally to the application, within the (server level) ejb3-interceptors-aop.xml file in the deploy folder. Of course they could even package a *-aop.xml within their application to do this.

           

          So are you and others expecting a similar feature in AS7 (ignore AOP and other implementation details part of it) where you can configure default activation properties to be applied to a MDB based on the environment where it's deployed, without having to update the deployment descriptors within the application? That IMO should be a feature we could implement by allowing named activation config properties configuration in the EJB3 subsystem and then letting the MDB somehow refer to that named config. But before going into that, I would like to really understand that this is what you and others are looking for.

          • 2. Re: Websphere MQ integration with MDB on AS7/EAP6 reloaded
            akrambenaissi

            Hi Jaikiran,

             

            basically, the need is exactly what you sum up:

             

            jaikiran pai wrote:

             

            So are you and others expecting a similar feature in AS7 (ignore AOP and other implementation details part of it) where you can configure default activation properties to be applied to a MDB based on the environment where it's deployed, without having to update the deployment descriptors within the application?

            Shortly: Being able to configure activation properties to be applied to and MDB without having to update the deployment desciptor.

             

            The evolution/implementation that you propose may fit the needs, but I want first to determine if there is not another solution, since all the informations to configure the queue used to "feed" the MDB are already present in some places.

            for example, here is a minimal suggested configuration that a customer proposed as a would like:

            This is of course specific to MQ: For the MDB, simply annotate it with :

            @MessageDriven( activationConfig = {
            @ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue = "java:jboss/jms/MyQueueConnectionFactory"),
            @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/jms/MyQueue"),
            @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true"), })
            

             

            While in the same time, defining the "java:jboss/jms/MyQueueConnectionFactory" and "java:jboss/jms/MyQueue" resources in the standalone.xml through the resource-adapters subsytem:

            Declaring such a resource adapter is made this way:

            <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
                        <resource-adapters>
                            <resource-adapter>
                                <archive>
                                    wmq.jmsra.rar
                                </archive>
                                <transaction-support>NoTransaction</transaction-support>
                                <connection-definitions>
                                    <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedQueueConnectionFactoryImpl" jndi-name="java:jboss/jms/MyQueueConnectionFactory" use-java-context="true" pool-name="MyConnectionFactoryPool">
                                        <config-property name="port">
                                            1416
                                        </config-property>
                                        <config-property name="hostName">localhost</config-property>
                                        <config-property name="channel">
                                            JBOSS.SVRCONN
                                        </config-property>
                                        <config-property name="transportType">
                                            CLIENT
                                        </config-property>
                                        <config-property name="queueManager">
                                            THE_WEBSPHERE_MQ_QUEUE_MANAGER
                                        </config-property>
                                        <pool>
                                            <min-pool-size>1</min-pool-size>
                                            <max-pool-size>10</max-pool-size>
                                        </pool>
                                        <security>
                                            <application/>
                                        </security>
                                    </connection-definition>
                                </connection-definitions>
                                <admin-objects>
                                    <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/MyQueue" use-java-context="true" pool-name="MyQueuePool">
                                        <config-property name="baseQueueName">
                                            THE_WEBSPHEREMQ_QUEUE_NAME
                                        </config-property>
                                        <config-property name="baseQueueManagerName">
                                            THE_WEBSPHERE_MQ_QUEUE_MANAGER
                                        </config-property>
                                    </admin-object>
                                </admin-objects>
                            </resource-adapter>
                        </resource-adapters>
            </subsystem>
            
            

             

            The resources are supposed to be registred in the JNDI directory and so unique.

            Would that be sufficient? Or is there a missing link? which I can't really determine?

            • 3. Re: Websphere MQ integration with MDB on AS7/EAP6 reloaded
              tiian

              Dear all,

              I created this thread http://www.mqseries.net/phpBB2/viewtopic.php?p=334834 inside a WebSphere MQ specific forum looking for a different way, on the WSMQ side, to remove the annotations.

              A WSMQ guru pointed me to this documentation: http://publib.boulder.ibm.com/infocenter/wmqv7/v7r1/topic/com.ibm.mq.doc/jm10790_.htm

              This is not easy stuff, but it might be useful to find a viable solution.

              The only jobmate of mine able to understand and try this suggestion is currently on holiday, so I can't figure out the results... until he will come back.

              Do you think this could be useful?

              Regards

              Ch.

              • 4. Re: Websphere MQ integration with MDB on AS7/EAP6 reloaded
                akrambenaissi

                As7 now supports deployment descriptors properties replacement.

                This is the most convenient solution to externalize admin objects configuration

                So used this

                • 5. Re: Websphere MQ integration with MDB on AS7/EAP6 reloaded
                  tiian

                  Do you know there is some documentation (and samples) about deployment descriptors properties replacement for WSMQ?

                  Thanks in advance

                  Ch.