Solution

  1. Download Websphere MQ from the following location and install it: http://www.ibm.com/developerworks/downloads/ws/wmq/
  2. Run the following command to create the necessary resources in MQ:
    Change directory to MQ_HOME/bin folder:
    - Create a MQ manager (Example: "COSI"):
    crtmqm COSI
    - Start the MQ Manager:
    strmqm COSI
    - Create local queue and channel:
    runmqsm
    DEFINE QLOCAL('DAVE') DEFPSIST(YES) //{Example: DAVE is the queuename}
    DEFINE CHANNEL(MAP.SVRCONN) CONNAME(SVRCONN) XMITQ(WW) //{Example: MAP.SVRCONN is the channel name}
    End
  3. Include weblogic.jar in the classpath and also include JRE in the path.
  4. Run the following command to start JMSAdmin:
    JMSAdmin.bat -v -cfg MyAdmin.cfg  //Example: MyAdmin.cfg is the file name
    Now JMSAdmin can be started. MyAdmin.config should have the following contents:
    Create :/JNDI-Directory
    INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
    PROVIDER_URL=file:/<windows-drive>:/JNDI-Directory
    SECURITY_AUTHENTICATION=none
  5. Next, create the QueueConnectionFactory and Queue objects by executing the command:
    C:\Program Files\IBM\WebSphere MQ\Java\bin\JMSAdmin.bat -cfg MyAdmin.config
    You should see this prompt, where you can configure the JNDI objects: InitCtx>
    At the prompt, type the following commands and press Enter after each one:
    def qcf(BUS.CMH.QCF) qmgr(COSI) CHANNEL(MAP.SVRCONN)    //{Example:BUS.CMH.QCF) is the queue Connection Factory name}
    def q(BUS.CMH.INI) qmgr(COSI) queue(DAVE)   //{Example: BUS.CMH.INI is the queue name}
    end
  6. When WLS and MQ are installed on different machines, we need to install MQ transactional client to successfully integrate WLS with MQ.
    Install MQ transactional client and then run MQ's JMSAdmin utility (Step 5) to bind MQ destination with a JNDI name. 
  7. Copy the following libraries in $domain_home/lib folder:
    - com.ibm.mq.jar
    - com.ibm.mqjms.jar
    - com.ibm.mqetclient.jar
    - fscontext.jar
    - dhbcore.jar 
  8. Start weblogic server
  9. Create Foreign JMS Server, JMS Module, subdeployment, Queueconnection factory and Foreign Destination 
  10. Access http://:/console, authenticating with the user name and password used in creating the WebLogic server instance above. After login, navigate to domain => Services => JMS => Foreign JMS Servers. In the right pane, click Configure a new Foreign JMSServer and enter the following values:
    Name: MQJMSTEST Foreign JMS Server
    JNDI Initial Context Factory: com.sun.jndi.fscontext.RefFSContextFactory
    JNDI Connection URL: file:/C:/JNDI-Directory
  11. Navigate to MQJMSTEST => Services => JMS => Foreign JMS Servers => MQJMSTEST Foreign JMS Server => Foreign JMS Connection Factories. In the right pane, click Configure a new Foreign JMSConnection Factory and enter the following values:
    Name: BUS.CMH.QCF
    Local JNDI Name: jms/BUS.CMH.QCF
    Remote JNDI Name: BUS.CMH.QCF
    The remote JNDI Name should match the QueueConnectionFactory name created in the file-based JNDI using the JMSAdmin tool.
  12. To create the destinations, navigate to MQJMSTEST => Services => JMS => Foreign JMS Servers => MQJMSTEST Foreign JMS Server => Foreign JMS Destinations. In the right pane, click Configure a new foreign JMSDestination and enter the following values:
    Name: BUS.CMH.INI
    Local JNDI Name: jms/BUS.CMH.INI
    Remote JNDI Name: BUS.CMH.INI
    The remote JNDI Name should match the destinations created in the file-based JNDI using the JMSAdmin tool.
  13. Here we use an MDB, TestMDB.zip, that is listening for the messages from DAVE in Queue manager COSI. The onMessage() method picks up the messages and prints a message about the same to the weblogic stdout.
  14. For sending a message to MQ, we need to use "Run listener command":
    runmqlsr -t tcp -p 1414 -m COSI
  15. Then we need to use amqsput DAVE COSI and type any numeric value as the actual message.
    example: 1000.
  16. You should see messages printed to the WLS standard output.
Thus integrating Websphere MQ with weblogic MDB is accomplished.

0 Comments