20.8. Deploy the WebSphere MQ Resource Adapter

About WebSphere MQ

WebSphere MQ is IBM's Messaging Oriented Middleware (MOM) software that allows applications on distributed systems to communicate with each other. This is accomplished through the use of messages and message queues. WebSphere MQ is responsible for delivering messages to the message queues and for transferring data to other queue managers using message channels. For more information about WebSphere MQ, see WebSphere MQ.

Summary

This topic covers the steps to deploy and configure the WebSphere MQ Resource Adapter in JBoss EAP 6. This can be accomplished by manually editing configuration files, using the Management CLI tool, or using the web-based Management Console.

Prerequisites

Before you get started, you must verify the version of the WebSphere MQ resource adapter and understand some of the WebSphere MQ configuration properties.

  • The WebSphere MQ resource adapter is supplied as a Resource Archive (RAR) file called wmq.jmsra-VERSION.rar. You must use version 7.0.1.7 or later.
  • You must know the values of the following WebSphere MQ configuration properties. Refer to the WebSphere MQ product documentation for details about these properties.
    • MQ.QUEUE.MANAGER: The name of the WebSphere MQ queue manager
    • MQ.HOST.NAME: The host name used to connect to the WebSphere MQ queue manager
    • MQ.CHANNEL.NAME: The server channel used to connect to the WebSphere MQ queue manager
    • MQ.QUEUE.NAME: The name of the destination queue
    • MQ.PORT: The port used to connect to the WebSphere MQ queue manager
    • MQ.CLIENT: The transport type
  • For outbound connections, you must also be familiar with the following configuration property:
    • MQ.CONNECTIONFACTORY.NAME: The name of the connection factory instance that will provide the connection to the remote system

Note

The following are default configurations provided by IBM and are subject to change. Please refer to WebSphere MQ documentation for more information.

Procedure 20.8. Deploy the Resource Adapter Manually

  1. If you need transaction support with the WebSphereMQ resource adapter, you must repackage the wmq.jmsra-VERSION.rar archive to include the mqetclient.jar. You can use the following command:
    [user@host ~]$ jar -uf wmq.jmsra-VERSION.rar mqetclient.jar
    Be sure to replace the VERSION with the correct version number.
  2. Copy the wmq.jmsra-VERSION.rar file to the EAP_HOME/standalone/deployments/ directory.
  3. Add the resource adapter to the server configuration file.
    1. Open the EAP_HOME/standalone/configuration/standalone-full.xml file in an editor.
    2. Find the urn:jboss:domain:resource-adapters subsystem in the configuration file.
    3. If there are no resource adapters defined for this subsystem, first replace:
      
      <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0"/>
      
      
      
      with this:
                        
      
      <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
          <resource-adapters>
              <!-- <resource-adapter> configuration listed below -->
          </resource-adapters>
      </subsystem>
      
      
      
    4. The resource adapter configuration depends on whether you need transaction support and recovery. If you do not need transaction support, choose the first configuration step below. If you do need transaction support, choose the second configuration step.
      • For non-transactional deployments, replace the <!-- <resource-adapter> configuration listed below --> with the following:
        
        <resource-adapter>
            <archive>
                wmq.jmsra-VERSION.rar
            </archive>
            <transaction-support>NoTransaction</transaction-support>
            <connection-definitions>
                <connection-definition 
                        class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" 
                        jndi-name="java:jboss/MQ.CONNECTIONFACTORY.NAME" 
                        pool-name="MQ.CONNECTIONFACTORY.NAME">
                    <config-property name="channel">
                        MQ.CHANNEL.NAME
                    </config-property>
                    <config-property name="transportType">
                        MQ.CLIENT
                    </config-property>
                    <config-property name="queueManager">
                        MQ.QUEUE.MANAGER
                    </config-property>
                    <security>
                        <security-domain>MySecurityDomain</security-domain>
                    </security>
               </connection-definition>
            </connection-definitions>
            <admin-objects>
                <admin-object 
                        class-name="com.ibm.mq.connector.outbound.MQQueueProxy" 
                        jndi-name="java:jboss/MQ.QUEUE.NAME" 
                        pool-name="MQ.QUEUE.NAME">
                    <config-property name="baseQueueName">
                        MQ.QUEUE.NAME
                    </config-property>
                </admin-object>
            </admin-objects>
        </resource-adapter>
        
        
        
        Be sure to replace the VERSION with the actual version in the name of the RAR.
      • For transactional deployments, replace the <!-- <resource-adapter> configuration listed below --> with the following:
        
        <resource-adapter>
            <archive>
                wmq.jmsra-VERSION.rar
            </archive>
            <transaction-support>XATransaction</transaction-support>
            <connection-definitions>
                <connection-definition 
                        class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" 
                        jndi-name="java:jboss/MQ.CONNECTIONFACTORY.NAME" 
                        pool-name="MQ.CONNECTIONFACTORY.NAME">
                    <config-property name="channel">
                        MQ.CHANNEL.NAME
                    </config-property>
                    <config-property name="transportType">
                        MQ.CLIENT
                    </config-property>
                    <config-property name="queueManager">
                        MQ.QUEUE.MANAGER
                    </config-property>
                   <security>
                        <security-domain>MySecurityDomain</security-domain>
                    </security>
                    <recovery>
                        <recover-credential>
                            <user-name>USER_NAME</user-name>
                            <password>PASSWORD</password>
                        </recover-credential>
                    </recovery>
                </connection-definition>
            </connection-definitions>
            <admin-objects>
                <admin-object 
                        class-name="com.ibm.mq.connector.outbound.MQQueueProxy" 
                        jndi-name="java:jboss/MQ.QUEUE.NAME" 
                        pool-name="MQ.QUEUE.NAME">
                    <config-property name="baseQueueName">
                        MQ.QUEUE.NAME
                    </config-property>
                </admin-object>
            </admin-objects>
        </resource-adapter>
        
        
        
        Be sure to replace the VERSION with the actual version in the name of the RAR. You must also replace the USER_NAME and PASSWORD with the valid user name and password.

        Note

        To support transactions, the <transaction-support> element was set to XATransaction. To support XA recovery, the <recovery> element was added to the connection definition.
    5. If you want to change the default provider for the EJB3 messaging system in JBoss EAP 6 from HornetQ to WebSphere MQ, modify the urn:jboss:domain:ejb3:1.2 subsystem as follows:
      Replace:
      
      <mdb>
          <resource-adapter-ref resource-adapter-name="hornetq-ra"/>
          <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
      </mdb>
      
      
      
      with:
      
      <mdb>
          <resource-adapter-ref resource-adapter-name="wmq.jmsra-VERSION.rar"/>
          <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
      </mdb>
      
      
      
      Be sure to replace the VERSION with the actual version in the name of the RAR.

Procedure 20.9. Modify the MDB code to use the resource adapter

  • Configure the ActivationConfigProperty and ResourceAdapter in the MDB code as follows:
    @MessageDriven( name="WebSphereMQMDB", 
        activationConfig =
        {
            @ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
            @ActivationConfigProperty(propertyName = "hostName", propertyValue = "MQ.HOST.NAME"),
            @ActivationConfigProperty(propertyName = "port", propertyValue = "MQ.PORT"),
            @ActivationConfigProperty(propertyName = "channel", propertyValue = "MQ.CHANNEL.NAME"),
            @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "MQ.QUEUE.MANAGER"),
            @ActivationConfigProperty(propertyName = "destination", propertyValue = "MQ.QUEUE.NAME"),
            @ActivationConfigProperty(propertyName = "transportType", propertyValue = "MQ.CLIENT")
        })
        @ResourceAdapter(value = "wmq.jmsra-VERSION.rar")
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public class WebSphereMQMDB implements MessageListener {
    }
    
    Be sure to replace the VERSION with the actual version in the name of the RAR.