IBM MQ is one of Message Queue implementation heavily used for interprocess communication in the software industry.
So I just crated a simple java client to talk to Queues and Topics in the IBM MQ.
Here I'm going to talk to the IBM MQ through the ".binding" file provided by the IBM MQ installation.
1. First you need to install the IBM MQ (I'm using windows machine to Install the IBM MQ).
2. Open IBM WebSphere MQ Explorer and do the following
Create Queue Manager as mymgr
Create Local Queue as localq
Create Local Topic as localt
3. Go to C:\Program Files\IBM\WebSphere MQ\java\bin, and invoke IVT app by running the following command:
IVTRun.bat –nojndi
If successful the following will be displayed:
4. Run the following command:
IVTRun.bat -nojndi -client -m mymgr -host localhost -channel mychannel
If successful the following will be displayed:
5. Navigate to to C:\IBM\WebSphere MQ\java\bin directory, open 'JMSAdmin.config' file and edit the file as follows:
a. Uncomment the configuration for INITIAL_CONTEXT_FACTORY
ex: INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
b. Point to an empty folder for PROVIDER_URL - ex: PROVIDER_URL=file:/C:/JNDI-Directory
6. Create the default set of JNDI bindings by running the following command in the command prompt:
IVTSetup.bat
If successful the following will be displayed:
7. Let's use the JMSAdmin tool to make some modifications in the JNDI bindings
Navigate to the C:\IBM\WebSphere MQ\java\bin directory from the console and start jmsadmin by running the following command:
jmsadmin.bat
Run the following commands:
For Queue:
ALTER QCF(ivtQCF) TRANSPORT(CLIENT)
ALTER QCF(ivtQCF) QMGR(mymgr)
For Topics:
ALTER TCF(ivtTCF) TRANSPORT(CLIENT)
ALTER TCF(ivtTCF) QMGR(mymgr)
8. Go to the "JMS Administered Objects" and select Add initial context. Then select the "File system" and enter the JNDI directory path. Then you can view all created Queues and Topics.
9. Now you can download the Java project here and open it form JIdea and make the following changes and run the client.
Replace your JNDI-Directory path
Replace the Queue Name and Queue connection factory name
Replace the Topic Name and Topic connection factory name
No comments:
Post a Comment