8 Replies Latest reply on Apr 20, 2017 3:55 AM by max016

    Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.

    max016

      Hi All,

       

      I am migrating my application from jboss4 to wildfly 8. We are listening to few JMS topics available over wmq at different hosts. In jboss-4 we had jboss-service.xml which contained few mbean related to that, my main concern is how can I configure same mbeans or jmx queues in wildfly's standalone.xml.

       

      jboss-service.xml (wmq configuration for jboss-4)

      <mbean code="jmx.service.wsmq.WSMQConnectionFactory"
               name="jmx.service.wsmq:service=MQQueueConnectionFactory">
          <attribute name="JndiName">MQQueueConnectionFactory</attribute>
          <attribute name="JMSStyle">Queue</attribute>
          <attribute name="IsXA">false</attribute>
          <attribute name="QueueManagerName">SQ0001</attribute>
          <attribute name="HostName">10.10.10.10</attribute>
          <attribute name="Port">****</attribute>
          <attribute name="Channel">SVRCONN</attribute>
          <attribute
              name="TransportType">MQJMS_TP_CLIENT_MQ_TCPIP</attribute>
          <depends>jboss:service=Naming</depends>
        </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
               name="jmx.service.wsmq:service=WSMQRequestQueue">
          <attribute name="JndiName">wsmq/RequestQueue</attribute>
          <attribute name="JMSStyle">Queue</attribute>
          <attribute name="QueueManagerName">SQ0001</attribute>
          <attribute
              name="DestinationName">PREPAID.REQ.QR02</attribute>
          <attribute name="TargetClient">MQ</attribute>
          <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
               name="jmx.service.wsmq:service=WSMQResponseQueue">
          <attribute name="JndiName">wsmq/ResponseQueue</attribute>
          <attribute name="JMSStyle">Queue</attribute>
          <attribute name="QueueManagerName">SQ0001</attribute>
          <attribute name="DestinationName">REPLY.QL05</attribute>
          <attribute name="TargetClient">MQ</attribute>
          <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
               name="jmx.service.wsmq:service=WSMQNMMResponseQueue">
          <attribute name="JndiName">wsmq/NMMResponseQueue</attribute>
          <attribute name="JMSStyle">Queue</attribute>
          <attribute name="QueueManagerName">SQ0001</attribute>
          <attribute name="DestinationName">REPLY.QL06</attribute>
          <attribute name="TargetClient">MQ</attribute>
          <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
               name="jmx.service.wsmq:service=WSMQBalanceResponseQueue">
           <attribute name="JndiName">wsmq/BalanceResponseQueue</attribute>
               <attribute name="JMSStyle">Queue</attribute>
           <attribute name="QueueManagerName">SQ0001</attribute>
               <attribute name="DestinationName">REPLY.QL07</attribute>
                   <attribute name="TargetClient">MQ</attribute>
               <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
               name="jmx.service.wsmq:service=WSMQExceptionQueue">
          <attribute name="JndiName">wsmq/exceptionQueue</attribute>
          <attribute name="JMSStyle">Queue</attribute>
          <attribute name="QueueManagerName">SQ0001</attribute>
          <attribute name="DestinationName">EXCEPTION.QL01</attribute>
          <attribute name="TargetClient">MQ</attribute>
          <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
               name="jmx.service.wsmq:service=WSMQLocalRequest">
          <attribute name="JndiName">wsmq/LocalRequestQueue</attribute>
          <attribute name="JMSStyle">Queue</attribute>
          <attribute name="QueueManagerName">SQ0001</attribute>
          <attribute name="DestinationName">LOCALREQUEST.QL01</attribute>
          <attribute name="TargetClient">MQ</attribute>
          <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
               name="jmx.service.wsmq:service=WSMQLocalERROR">
          <attribute name="JndiName">wsmq/ERRORQ</attribute>
              <attribute name="JMSStyle">Queue</attribute>
           <attribute name="QueueManagerName">SQ0001</attribute>
              <attribute name="DestinationName">ERROR.QL01</attribute>
           <attribute name="TargetClient">MQ</attribute>
               <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
              name="jmx.service.wsmq:service=WSMQDemoRequestQueue">
              <attribute name="JndiName">wsmq/DemoRequestQueue</attribute>
              <attribute name="JMSStyle">Queue</attribute>
              <attribute name="QueueManagerName">SQ0001</attribute>
              <attribute name="DestinationName">REQUEST.QL05</attribute>
              <attribute name="TargetClient">MQ</attribute>
              <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination"
              name="jmx.service.wsmq:service=WSMQNotificationServiceQueue">
              <attribute name="JndiName">wsmq/NotificationServiceQueue</attribute>
              <attribute name="JMSStyle">Queue</attribute>
              <attribute name="QueueManagerName">SQ0001</attribute>
              <attribute name="DestinationName">REQUEST.QL05</attribute>
              <attribute name="TargetClient" value="0"/>
              <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQConnectionFactory" name="jmx.service.wsmq:service=DemoProjBusTopicConnectionFactory">
        <attribute name="JndiName">jms/tcf/Notification</attribute>
        <attribute name="JMSStyle">Topic</attribute>
        <attribute name="IsXA">true</attribute>
        <attribute name="QueueManagerName">SQ0001</attribute>
        <attribute name="HostName">****.****.com</attribute>
        <attribute name="Port">****</attribute>
        <attribute name="Channel">SVRCONN</attribute>
        <attribute name="TransportType">MQJMS_TP_CLIENT_MQ_TCPIP</attribute>
        <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQDestination" name="jmx.service.wsmq:service=WSMQDemoProjEventTopic">
        <attribute name="JndiName">jms/topic/DemoProjEvent</attribute>
        <attribute name="JMSStyle">Topic</attribute>
        <attribute name="QueueManagerName">SQ0001</attribute>
        <attribute name="DestinationName">DemoProjEvent.dev1</attribute>
        <attribute name="TargetClient" value="0" />
        <attribute name="Persistence">MQJMS_PER_PER</attribute>
        <depends>jboss:service=Naming</depends>
      </mbean>
      <mbean code="jmx.service.wsmq.WSMQConnectionFactory" 
        name="jmx.service.wsmq:service=DemoProjEventTopicConnectionFactory">
        <attribute name="JndiName">jms/tcf/NotificationSubscriber</attribute>
        <attribute name="JMSStyle">Topic</attribute>
        <attribute name="IsXA">true</attribute>
        <attribute name="QueueManagerName">SQ0001</attribute>
        <attribute name="HostName">***.*****.com</attribute>
        <attribute name="Port">****</attribute>
        <attribute name="Channel">SVRCONN</attribute>
        <attribute name="TransportType">MQJMS_TP_CLIENT_MQ_TCPIP</attribute>
        <depends>jboss:service=Naming</depends>
      </mbean>
      

       

      I have gone through below blog for configuring wmq in wildfly's standalone but all I can see is there is one Connection Factory and one Admin Object, but I need to add all these mbeans.
      https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Administration_and_Configuration_Guide/Deploy_the_WebSphere_MQ_Resource_Adapter.html

        • 1. Re: Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.
          jbertram

          Can you not simply add as many connection factories and admin objects as you need using the syntax demonstrated in the documentation you linked?

          • 2. Re: Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.
            max016

            Hi Justin,

             

            Thanks for the reply buddy.

             

            I have added connection factory as shown in link I attached but there are few concerns as below.

             

            1) In given link connection factory class is "com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" (class available in jmx.jar) where as in my older configuration it was jmx.service.wsmq.WSMQConnectionFactory. (available in 8.X-wmq.jmsra.rar --- Is it because I also updated my wmq-adapter from version 4.X to 8.X)

             

            2) After adding below xml configuration wildfly is not able to map objects corresponding to jndi names. Below is snippet from my standalone.xml file.

            <resource-adapter id="wmq.jmsra.rar">
              <module slot="main" id="com.ibm.wmq.jmsra"/>
              <transaction-support>XATransaction</transaction-support>
              <connection-definitions>
              <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:/MQQueueConnectionFactory" enabled="true" pool-name="MQQueueConnectionFactory">
              <security>
              <application/>
              </security>
              <validation>
              <background-validation>false</background-validation>
              </validation>
              </connection-definition>
              </connection-definitions>
              <admin-objects>
              <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:/wsmq/NotificationServiceQueue" enabled="true" use-java-context="false" pool-name="wsmq/NotificationServiceQueue"/>
              </admin-objects>
            </resource-adapter>
            

            ** I have added module com.ibm.wmq.jmsra in wildfly's modules/system/layers/base directory and I am not getting any error regarding that but my JNDI View from Admin Console is showing '?' for objects against newly added JNDI names like below.

            jndi_view.jpg

             

            So bottom line is, now I am getting Spring's DI related exception as we are referring this connection factory into spring's JmsTemplate's bean.

            Exception :

            Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [com/project/jms/jmsContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Specified a Spring JMS 1.0.2 template for queues but did not supply an instance of QueueConnectionFactory

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

                    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)

                    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

                    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)

                    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)

                    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)

                    ... 34 more

            Caused by: java.lang.IllegalArgumentException: Specified a Spring JMS 1.0.2 template for queues but did not supply an instance of QueueConnectionFactory

                    at org.springframework.jms.core.JmsTemplate102.afterPropertiesSet(JmsTemplate102.java:140)

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)

                    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)

                    ... 41 more

             

            Also here is my jmsContext.xml file for reference.

            <?xml version="1.0" encoding="UTF-8"?>
            <beans xmlns="http://www.springframework.org/schema/beans"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
            
            <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
              <property name="environment">
              <props>
              <prop key="java.naming.factory.initial">
              ${java.naming.factory.initial}
              </prop>
              <prop key="java.naming.factory.url.pkgs">
              ${java.naming.factory.url.pkgs}
              </prop>
              <prop key="java.naming.provider.url">
              ${java.naming.provider.url}
              </prop>
              </props>
              </property>
            </bean>
            
            <bean id="jmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiTemplate" ref="jndiTemplate"/>
              <property name="jndiName">
              <value>MQQueueConnectionFactory</value>
              </property>
            </bean>
            
            <bean id="requestQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiTemplate" ref="jndiTemplate"/>
              <property name="jndiName">
              <value>wsmq/NotificationServiceQueue</value>
              </property>
            </bean>
            
            <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate102">
              <property name="connectionFactory" ref="jmsQueueConnectionFactory"/>
              <property name="defaultDestination" ref="requestQueue"/>
              <property name="sessionTransacted" value="true" />
            </bean>
            

             

            I have tried restarting server, adding archive (.rar) instead of module both did not work, Kindly help.

            • 3. Re: Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.
              jbertram

              1) In given link connection factory class is "com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" (class available in jmx.jar) where as in my older configuration it was jmx.service.wsmq.WSMQConnectionFactory. (available in 8.X-wmq.jmsra.rar --- Is it because I also updated my wmq-adapter from version 4.X to 8.X)

              I'm not sure why it changed, but my guess is that you don't need jmx.service.wsmq.WSMQConnectionFactory anymore because you don't need to configure it as a JMX MBean now like you did in JBoss AS 4.x.

               

              2) After adding below xml configuration wildfly is not able to map objects corresponding to jndi names. Below is snippet from my standalone.xml file.

              It may be because you haven't passed the configuration details necessary to actually set up the connection factory and/or destination (e.g. hostname, port, channel name, etc.).  But that's just a guess.

               

              Caused by: java.lang.IllegalArgumentException: Specified a Spring JMS 1.0.2 template for queues but did not supply an instance of QueueConnectionFactory

              This is probably because you're forcing the Spring client to use the 1.0.2 interfaces but com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl is giving you a javax.jms.ConnectionFactory (which 1.0.2 doesn't support).  You could try using org.springframework.jms.core.JmsTemplate instead or configuring "java:/MQQueueConnectionFactory" specifically to be a queue connection factory.

              1 of 1 people found this helpful
              • 4. Re: Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.
                max016

                Caused by: java.lang.IllegalArgumentException: Specified a Spring JMS 1.0.2 template for queues but did not supply an instance of QueueConnectionFactory

                This is probably because you're forcing the Spring client to use the 1.0.2 interfaces but com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl is giving you a javax.jms.ConnectionFactory (which 1.0.2 doesn't support).  You could try using org.springframework.jms.core.JmsTemplate instead or configuring "java:/MQQueueConnectionFactory" specifically to be a queue connection factory.

                PERFECT !!!

                Thanks jbertram, seriously man I owe you a big time.

                 

                As you said "com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl is giving a javax.jms.ConnectionFactory only"  the instance of check in code of JmsTemplate102's code fails and throws an exception.

                 

                /**
                 * In addition to checking if the connection factory is set, make sure
                 * that the supplied connection factory is of the appropriate type for
                 * the specified destination type: QueueConnectionFactory for queues,
                 * and TopicConnectionFactory for topics.
                 */
                public void afterPropertiesSet() {
                  super.afterPropertiesSet();
                
                
                  // Make sure that the ConnectionFactory passed is consistent.
                  // Some provider implementations of the ConnectionFactory interface
                  // implement both domain interfaces under the cover, so just check if
                  // the selected domain is consistent with the type of connection factory.
                  if (isPubSubDomain()) {
                  if (!(getConnectionFactory() instanceof TopicConnectionFactory)) {
                  throw new IllegalArgumentException(
                  "Specified a Spring JMS 1.0.2 template for topics " +
                  "but did not supply an instance of TopicConnectionFactory");
                  }
                  }
                  else {
                  if (!(getConnectionFactory() instanceof QueueConnectionFactory)) {
                  throw new IllegalArgumentException(
                  "Specified a Spring JMS 1.0.2 template for queues " +
                  "but did not supply an instance of QueueConnectionFactory");
                  }
                  }
                }
                

                So this issue was resolved after replacing JmsTemplate102 with parent class JmsTemplate.

                 

                2) After adding below xml configuration wildfly is not able to map objects corresponding to jndi names. Below is snippet from my standalone.xml file.

                It may be because you haven't passed the configuration details necessary to actually set up the connection factory and/or destination (e.g. hostname, port, channel name, etc.).  But that's just a guess.

                I had added hostname, port and channel name etc. properties under system properties tag in standalone.xml, also tried by directly providing as text in my jmscontext.xml still did not work.

                 

                For now my work is not hampered but still I can not see any objects against the jndi names as shown in previous image. Can you please also help me resolving that as well.

                JNDI view from CLI command :

                [standalone@192.**.**.**:9990 /] /subsystem=naming:jndi-view

                {

                    "outcome" => "success",

                    "result" => {

                        "java: contexts" => {

                            "java:" => {

                                "MQQueueConnectionFactory" => {

                                    "class-name" => "java.lang.Object",

                                    "value" => "?"

                                },

                                "TransactionManager" => {

                                    "class-name" => "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate",

                                    "value" => "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@7e41ba1e"

                                },

                                "wsmq" => {

                                    "class-name" => "javax.naming.Context",

                                    "children" => {

                                        "notificationServiceQueue" => {

                                            "class-name" => "java.lang.Object",

                                            "value" => "?"

                                        }

                                    }

                                },

                 

                Here is my module.xml which I added for Resource Adapter wmq.jmsra.rar. I have kept it at /modules/system/layers/base/com/ibm/wmq/jmsra/main with all mentioned jars.

                <module xmlns="urn:jboss:module:1.1" name="com.ibm.wmq.jmsra">
                <resources>
                  <resource-root path="."/>
                  <resource-root path="com.ibm.mqetclient.jar"/>
                  <resource-root path="com.ibm.mq.connector.jar"/>
                  <resource-root path="com.ibm.mq.headers.jar"/>
                  <resource-root path="com.ibm.mq.jmqi.jar"/>
                  <resource-root path="com.ibm.mq.pcf.jar"/>
                  <resource-root path="com.ibm.mq.jar"/>
                  <resource-root path="com.ibm.mqjms.jar"/>
                </resources> 
                <dependencies>
                  <module name="javax.api"/>
                  <module name="javax.resource.api"/>
                  <module name="javax.jms.api"/>
                  <module name="javax.management.j2ee.api"/>
                </dependencies>  
                </module>
                

                 

                I also added global-modules tag in standalone.xml for making this custom module available for class loading.

                 <subsystem xmlns="urn:jboss:domain:ee:2.0">
                            <global-modules>
                                <module name="com.ibm.wmq.jmsra" slot="main"/>
                            </global-modules>
                

                 

                Kindly help.

                • 5. Re: Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.
                  jbertram

                  I had added hostname, port and channel name etc. properties under system properties tag in standalone.xml...

                  I'm not clear on how system properties would work in this use-case.  Are certain system property values automatically used by the WSMQ JCA RA?  Why not simply use <config-property> elements as demonstrated in the linked documentation?

                   

                  ...also tried by directly providing as text in my jmscontext.xml still did not work.

                  Is it possible to configure the WSMQ JCA RA from the jmscontext.xml?  Please elaborate.

                  1 of 1 people found this helpful
                  • 6. Re: Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.
                    max016

                    Ohh ok you mean that configuration, I also felt that when you mentioned about channel name. Yes that configuration (host, port and channel) goes within <resource-adapter>'s tag only.  Actually I was thinking about jmscontext.xml's (java.naming.provider.url) properties value.

                     

                    So, I assume once I set configuration, connectionFactory object will be provided by Queue Manager and right now my Queue Manager is not yet set up at WMQ so I need to wait till then.

                    • 7. Re: Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.
                      jbertram

                      I assume your Spring application is running in the same JVM as the Wildfly server.  If that's the case then you shouldn't need to set any properties on your InitialContext.  A blank InitialContext will automatically connect to the in-VM JNDI server.

                       

                      As noted previously, my guess is that since the WSMQ JCA RA can't actually connect to a valid WSMQ instance then it can't properly create the connection factory.  If you set up your WSMQ instance and properly configure the JCA RA to connect to it and it still doesn't work then come back on this thread and explain the situation.

                      1 of 1 people found this helpful
                      • 8. Re: Migrating from jboss 4.0.5 GA to WildFly 8.2 || websphere-mq related configuration.
                        max016

                        Hi Justin,

                         

                        This was the only problem after solving that I was able to communicate with MQ, actually in this thread you solved 2-3 problems but I think this one was very important and hard for anyone to identify so marking this as correct answer. Thanks a lot for you help and immediate response for every time. Though I am still getting those question marks in Admin-Conse->JNDIview for MQConnectionFactory and QueueName instead of the Objects (shown as below) but I can see my ip in MQs logs, so I don't care about this issue anymore.

                         

                        I am very happy that now it is working as expected, Thank you so much again.

                         

                        jndi_view.jpg