Introduction to WebSphere Message Queue:
Tutorial 1: Sending a message to a local queue
Creating the Queue Manager:
Enter Queue manager name, QM_APPLE
Leave other fields as default values and Click NEXT twice and ensure queue manager startup as
Automatic and click NEXT.
Ensure Create listener configuration for TCP/IP box is checked
If the Finish button is not available, type another port number in the Listen on port number field. If
the current value is 1414, try using a different port number, for example: 1415 or 1416. If the default
port number of 1414 is not used at this stage, make a note of the port number used because you will
need it in later stages of this tutorial when QM_APPLE serves as a receiving queue manager. Click
Finish.
Result
Once its been created the Queue manager starts running automatically.
Creating the queue manager using MQSC
Open a command prompt, and follow these steps:
Procedure
1. Create a queue manager called QM_APPLE by typing the command:
crtmqm QM_APPLE
Messages tell you that the queue has been created and that the default WebSphere MQ objects
have been created.
2.
Start this queue manager by typing the command:
strmqm
A message tells you when the queue manager has started.
Results
You have now created a queue manager with the name QM_APPLE.
Creating the local queue
Expand Queue Manage QM_APPLE and create a new Local Queue
The New Local Queue wizard opens. In the Name field, type Q1 and Click Finish.
Result
Local Queue Q1 is displayed in content view.
Creating the local queue using MQSC
Open a command prompt and follow these steps:
Procedure
1. Enable MQSC commands by typing the command:
runmqsc
2.
Type the following command:
define qlocal (Q1)
3.
4.
Messages tell you that the queue has been created and that the default WebSphere MQ objects
have been created.
Stop MQSC by typing the command:
End
Results
You have now created a local queue called Q1.
Putting a test message on the local queue
In content view of Local Queue, right-click the local queue Q1, then click Put Test Message.
Type some Message data Sample Test Meessage for Checking Flow of Message Queue, then click Put
message. The Message data field is cleared and the message is put on the queue and Click Close.
Result
Current queue depth value is 1 now,
Putting a test message on the queue using amqsput
The amqsput sample program is used to put a message on the queue that you created. On Windows
the sample programs are installed by default with WebSphere MQ Server or Client. On Linux, the
samples programs RPM need to be installed.
Procedure
1.
Start the amqsput sample program as follows:
o On Linux, change to the MQ_INSTALLATION_PATH/samp/bin directory, where
MQ_INSTALLATION_PATH represents the high-level directory in which WebSphere MQ is
installed. Type the command:
./amqsput Q1 QM_APPLE
o
On Windows, type the command:
amqsput Q1 QM_APPLE
1.
The following messages are displayed:
Sample AMQSPUT0 start
target queue is Q1
Type some message text on one or more lines, then press Enter twice. The following message
is displayed:
Sample AMQSPUT0 end
Results
You have now created a test message and put it onto the local queue.
Verifying that the test message was sent
In content view of Local Queue, right-click the local queue Q1, then click Browse Messages.
Message browser opens to show the list of messages that are currently on Q1
Double-click the last message to open its properties dialog.
Results
On the Data page of the properties dialog, the Message data field displays the content of the
message.
Verifying that the test message was sent using amqsget
Open a command prompt, and follow these steps:
Procedure
Start the amqsget sample program:
On Windows, type the following command:
amqsget Q1 QM_APPLE
On Linux, change to the MQ_INSTALLATION_PATH/samp/bin directory, where
MQ_INSTALLATION_PATH represents the high-level directory in which WebSphere MQ is
installed. Type the following command:
./amqsget Q1 QM_APPLE
Results
The sample program starts, and your message is displayed along with any other messages on this
queue. After a pause of 15 seconds, the sample ends and the command prompt is displayed again.
Tutorial 2: Sending a message to a remote queue
Creating the queue manager on the sending machine
Create New Queue manager QM_ORANGE using WebSphere MQ Explorer or using command:
crtmqm QM_ORANGE
Once the setup completed, you can view the created Queue manager in MQ explorer-Stopped status.
Start this queue manager by typing the command: strmqm QM_ORANGE
You can view the Queue manager up and running in MQ explorer.
When using MQ explorer to create Queue manager for remote queue connection Select Create
server-connection channel
Creating the queues on the sending queue manager
Right-click the Queues folder under QM_ORANGE, then click New Remote Queue Definition.
The New Remote Queue Definition wizard opens, fill Remote queue infm and click Finish.
Right-click the Queues folder under QM_ORANGE, then click New Local Queue.
Queue name as QM_APPLE and Usage as Transmission. Click Finish and Transmission queue has been
created. New queues, Q1 and QM_APPLE, are displayed in the Content view.
Creating a message channel
Receiver Channel
On the receiving queue manager QM_APPLE, create the receiver end of the channel:
a.
b.
In the Navigator view, expand the queue manager QM_APPLE that we created earlier.
Right-click the Channels folder, then click New Receiver Channel.
c.
d.
The New Receiver Channel wizard opens. In the Name field, type QM_ORANGE.QM_APPLE
Click Finish. You have now created the receiver channel on the receiving machine.
Sender Channel
On the sending queue manager QM_ORANGE, create the sender end of the channel:
a. In the Navigator view, expand the queue manager QM_ORANGE that we created earlier.
b. Right-click the Channels folder, then click New Sender Channel.
c.
d.
e.
The New Sender Channel wizard opens. In the Name field, type QM_ORANGE.QM_APPLE,
then click NEXT.
In the Connection name field, type the computer name or IP address of the receiving machine
(you should already have obtained this with your system administrator's help).
If the default port number 1414 was not used when creating QM_APPLE, the Connection name
field entry should be of the format:
con-name (port)
f.
Where con-name is the computer name or IP address of the receiving machine, and port is the
port number used when the receiving queue manager was set up.
In the Transmission queue field, type QM_APPLE and Click Finish.
g.
h.
Click the Channels folder. Right-click QM_ORANGE.QM_APPLE.
From the pop-up menu, click Start. Click OK. You have now created the sender channel on the
sending machine.
Note: You do not have to start the receiver channel because it started automatically
when you set up the sender channel (when you set up the sender channel, you
specified the receiver channel's IP address).
Putting a test message on Queue
The amqsput sample program is used to put a message onto the queue that you created.
Open a command prompt and follow these steps:
Procedure
1. Start the amqsput sample program as follows:
o On Linux, change to the /opt/mqm/samp/bin directory and type the command:
./amqsput Q1 QM_ORANGE
o
On Windows, type the command:
amqsput Q1 QM_ORANGE
The following messages are displayed:
Sample amqsput0 start
target queue is Q1
2.
Type some message text on one or more lines, then press Enter twice. The following message
is displayed:
Sample amqsput0 end
Results
You have now created a test message and put it onto the remote queue. The next task is to verify that
the test message was received.
Verifying that the test message was sent using WebSphere MQ
Explorer
On the receiving queue manager (QM_APPLE):
In the Content view, right-click the queue Q1, then click Browse Messages. The Message
browser opens to show the list of the messages that are currently on Q1
. Double click the last message in the list to view its properties dialog.