- Create a JMS module and add the resource Foreign Server as below:
- Go to the ForeignServer-> Configuration-> General and edit it as below:
JNDI Initial Context Factory: com.sun.jndi.fscontext.RefFSContextFactory
JNDI Connection URL: file:/C:/JNDI-Directory
It looks like:
- Go to Configurations -> Destinations-> Click on new.
Give the Local JNDI name as the JNDI which is on the weblogic side and is in the deployment descriptors of the MDB. The remote JNDI name will be the queue names which are on the MQ side.
It looks like:
- Go to Configurations -> connection factory and click on new.
The local JNDI name will be the connection factory name in the deployment descriptors of the MDB and the remote connection factory will be the one on MQ side.
It looks like:
- Note: These destinations are logical entities and not actually present. These destinations cannot be monitored.
This is an example of the MDB and the foreign JMS server being on the same domain and the same server. Deploy your MDB on the same server on which the JMS server is targeted. In this case it is the admin server. The deployed MDB will look like below:
Configurations in the MDB according to the screen shots will be:
- weblogic-ejb-jar.xml file: (example of destination queue)
Below are the configurations from MQ side that need to be done so that the MQ can bind with the weblogic server:
- Create a folder in C:\ drive with the name JNDI-Directory (mention the drive/path where you have MQ installed)
- Create a file named MyAdmin.config in the path “C:\Program Files\IBM\WebSphere MQ\Java\bin”, write the below in the file:
- Copy all the MQ related jars in the classpath of the server:
set classpath=”C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jms.Nojndi.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mq.soap.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mqjms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\connector.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\fscontext.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\fscontext.jar”;%CLASSPATH%
To create and run the MQ queue manager, below are the commands:
- C:\Program Files\IBM\WebSphere MQ\Java\bin>crtmqm testqmgr
- C:\Program Files\IBM\WebSphere MQ\Java\bin>strmqm testqmgr
- C:\Program Files\IBM\WebSphere MQ\Java\bin>runmqsc testqmgr
- To create the connection factory and the queues on MQ as per your naming requirement.
Go to the command prompt and go to the below path:
C:\Program Files\IBM\WebSphere MQ\Java\bin\
- Ensure that you have a MyAdmin.Config file in the above path in your system.
- Type the command JMSAdmin.bat -cfg MyAdmin.config and you will see InitCtx> in the prompt shell.
Examples of creating connection factory and queue:
InitCtx> def xaqcf(ReceiverQCF) qmgr(testqmgr)
- Now check the bindings of weblogic with the MQ as below:
InitCtx> display ctx
Contents of InitCtx
a ReceiverQCF com.ibm.mq.jms.MQXAQueueConnectionFactory
a J3.Q0038.V3 com.ibm.mq.jms.MQQueue
a J3.Q0015.V3 com.ibm.mq.jms.MQQueue
a J3.Q0002.V3 com.ibm.mq.jms.MQQueue
5 Binding(s), 4 Administered
Check if the bindings file is created in the JNDI-Directory folder.