Integrating Oracle WebLogic Server with Websphere MQ
Solution
- Download Websphere MQ from the following location and install it: http://www.ibm.com/developerworks/downloads/ws/wmq/
- 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:
- Include weblogic.jar in the classpath and also include JRE in the path.
- Run the following command to start JMSAdmin:
JMSAdmin.bat -v -cfg MyAdmin.cfg //Example: MyAdmin.cfg is the file nameNow 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 - Next, create the QueueConnectionFactory and Queue objects by executing the command:
C:\Program Files\IBM\WebSphere MQ\Java\bin\JMSAdmin.bat -cfg MyAdmin.configYou 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 - 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. - 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 - Start weblogic server
- Create Foreign JMS Server, JMS Module, subdeployment, Queueconnection factory and Foreign Destination
- 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 - 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.QCFThe remote JNDI Name should match the QueueConnectionFactory name created in the file-based JNDI using the JMSAdmin tool.
Local JNDI Name: jms/BUS.CMH.QCF
Remote JNDI Name: BUS.CMH.QCF - 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.INIThe remote JNDI Name should match the destinations created in the file-based JNDI using the JMSAdmin tool.
Local JNDI Name: jms/BUS.CMH.INI
Remote JNDI Name: BUS.CMH.INI - 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.
- For sending a message to MQ, we need to use "Run listener command":
runmqlsr -t tcp -p 1414 -m COSI - Then we need to use amqsput DAVE COSI and type any numeric value as the actual message.
example: 1000. - You should see messages printed to the WLS standard output.
0 Comments