Date Created: Fri 05-Sep-2008

Related Document Categories:

Get my WebSphere MQ course here >> http://www.themiddlewareshop.com/products/


    This is how I learned how to talk to a remote Queue. The example below is my adaption of the tutorial found in the windows MQ getting started guide.

    Sending a message to a remote queue

    A visual summary of what you will
achieve in this tutorial. For more information, see the first
page of the tutorial.

    This tutorial shows you how to set up messaging between a queue manager, QM_ORANGE, on one computer and a queue manager, QM_APPLE, on another computer. A message that is created on the first computer is delivered to a queue, Q1, on the second computer (this queue is referred to as a remote queue).

    This tutorial builds upon MQ objects that have been set up during the previous tutorial; you need to have completed Sending a message to a local queue.

    Important: During this tutorial, you will use the machine on which you created queue manager QM_APPLE and local queue Q1 as the receiving machine.

    You will set up a queue manager and queues (a remote queue definition and a transmission queue) on the sending machine. You will then define a message channel. Finally, you will put a test message onto the sending machine, and get it from the queue on the receiving machine.

    Before starting this tutorial, you will need to find out, from your system administrator, the name that identifies the receiving machine on the network.

    When you have completed this tutorial, you should have a basic understanding of how to set up and use WebSphere MQ messaging using a remote queue definition.

    Creating the sending queue manager using MQSC

    Sending Machine=websphere2.fedora.com

    Open a command prompt on the sending machine and follow these steps:

    1. Create a default queue manager called QM_ORANGE by typing the command:

    crtmqm -q QM_ORANGE

    [mqm@websphere2 ~]$ crtmqm -q QM_ORANGE
    WebSphere MQ queue manager created.
    Creating or replacing default objects for QM_ORANGE.
    Default objects statistics : 40 created. 0 replaced. 0 failed.
    Completing setup.
    Setup completed.

    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

    [mqm@websphere2 ~]$ strmqm QM_ORANGE
    WebSphere MQ queue manager 'QM_ORANGE' starting.
    5 log records accessed on queue manager 'QM_ORANGE' during the log replay phase.
    Log replay for queue manager 'QM_ORANGE' complete.
    Transaction manager state recovered for queue manager 'QM_ORANGE'.
    WebSphere MQ queue manager 'QM_ORANGE' started.
    [mqm@websphere2 ~]$

    A message tells you when the queue manager has started.

    3. You must now create a listener by typing the command: It is not obvious in the IBM tutorial but the listener on the first WebSphere MQ machine in my case websphere.fedora6.com

    Receiving Machine: websphere.fedora.com

    runmqlsr -m QM_APPLE -t TCP -p (port number)

    You cannot use rummqlsr unless the queue is running, also make sure that a queue exists:

    crtmqm QM_APPLE

    strmqm QM_APPLE

    runmqsc QM_APPLE
    Starting MQSC for queue manager QM_APPLE.

    AMQ8146: WebSphere MQ queue manager not available.

    strmqm QM_APPLE


    -bash-3.1$ strmqm QM_APPLE
    WebSphere MQ queue manager 'QM_APPLE' starting.
    5 log records accessed on queue manager 'QM_APPLE' during the log replay phase.
    Log replay for queue manager 'QM_APPLE' complete.
    Transaction manager state recovered for queue manager 'QM_APPLE'.
    WebSphere MQ queue manager 'QM_APPLE' started.
    -bash-3.1$ runmqsc QM_APPLE
    5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
    Starting MQSC for queue manager QM_APPLE.


    define qlocal (Q1)
    1 : define qlocal (Q1)
    AMQ8006: WebSphere MQ queue created.
    end
    2 : end
    One MQSC command read.
    No commands have a syntax error.
    All valid MQSC commands were processed.

    runmqlsr -m QM_APPLE -t TCP -p 60000

    it hangs however ??

    OK, I have to press CTRL+C to break it. I need to run it as a background task: Make sure all runmqlsr are killed
    -bash-3.1$ runmqlsr -m QM_APPLE -t TCP -p 60000 -i 192.168.0.60 & <enter><enter>


    [1] 32101
    -bash-3.1$ 5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.

    The & ensures the task is run in the back ground.

    Note: If you do not specify anything with the -p parameter, the default port 1414 is used, but note that you cannot use the same port number on the sender and receiver, so one could be 1414 and the other 1415 for example.

    You have now created the sending queue manager. The next task is to create the queues on this queue manager.

    Creating the queues on the sending queue manager using MQSC

    Sending Machine: websphere2.fedora6.com

    Once again we go back to the Remote Queue Manager called QM_ORANGE on WebSphere.fedora6.com

    Open a command prompt on the sending machine and follow these steps:

    1. Start MQSC by typing the command:

    runmqsc QM_ORANGE

    A message tells you that an MQSC session has started.

    2. Define a local queue called QM_APPLE by typing the following command:

    define qlocal (QM_APPLE) usage (xmitq)

    A message tells you when the queue has been created.

    3. Define a remote queue definition by typing the following command:

    define qremote (Q1) rname (Q1) rqmname(QM_APPLE) xmitq (QM_APPLE)


    [mqm@websphere2 ~]$ runmqsc
    5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
    Starting MQSC for queue manager QM_ORANGE.


    define qlocal (QM_APPLE) usage (xmitq)
    1 : define qlocal (QM_APPLE) usage (xmitq)
    AMQ8006: WebSphere MQ queue created.
    define qremote (Q1) rname (Q1) rqmname(QM_APPLE) xmitq (QM_APPLE)
    2 : define qremote (Q1) rname (Q1) rqmname(QM_APPLE) xmitq (QM_APPLE)
    AMQ8006: WebSphere MQ queue created.
    end
    3 : end
    2 MQSC commands read.
    No commands have a syntax error.
    All valid MQSC commands were processed.

    -------------------------------------------------------------

    xmitq: Transmission queue name (XMITQ)Transmission queue name (XMITQ). The name of the transmission queue from which messages are retrieved.

    -------------------------------------------------------------

    Creating the message channel using MQSC

    We go to receiving machine: websphere.fedora.com

    Open a command prompt on the receiving machine and follow these steps:

    1. Start MQSC by typing the command:

    runmqsc QM_APPLE

    A message tells you that an MQSC session has started.

    2. Define a receiving channel by typing the following command:

    define channel (QM_ORANGE.QM_APPLE) chltype (RCVR) trptype (TCP)

    A message tells you when the channel has been created.

    3. Stop MQSC by typing:

    end

    Some messages are displayed followed by the command prompt.


    -bash-3.1$ 5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
    -bash-3.1$ runmqsc
    5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
    Starting MQSC for queue manager QM_APPLE.


    define channel (QM_ORANGE.QM_APPLE) chltype (RCVR) trptype (TCP)
    1 : define channel (QM_ORANGE.QM_APPLE) chltype (RCVR) trptype (TCP)
    AMQ8014: WebSphere MQ channel created.
    end
    2 : end
    One MQSC command read.
    No commands have a syntax error.
    All valid MQSC commands were processed.

    Go to websphere2.fedora.com

    Open a command prompt on the sending machine and follow these steps:

    4. Start MQSC by typing the command:

    runmqsc QM_ORANGE

    A message tells you that an MQSC session has started.

    5. Define a sender channel by typing the following command:

    define channel (QM_ORANGE.QM_APPLE) chltype (sdr) conname ('con-name') xmitq (QM_APPLE) trptype (tcp)

    define channel (QM_ORANGE.QM_APPLE) chltype (sdr) conname ('192.168.0.60') xmitq (QM_APPLE) trptype (tcp)

    The value con-name is the TCP address of the receiver queue manager.

    6. Start the channel by typing the following command:

    start channel (QM_ORANGE.QM_APPLE)

    7. Stop MQSC by typing:

    end

    Some messages are displayed followed by the command prompt.


    [mqm@websphere2 ~]$ runmqsc
    5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
    Starting MQSC for queue manager QM_ORANGE.


    define channel (QM_ORANGE.QM_APPLE) chltype (sdr) conname ('192.168.0.60') xmitq (QM_APPLE) trptype (tcp)
    1 : define channel (QM_ORANGE.QM_APPLE) chltype (sdr) conname ('192.168.0.60') xmitq (QM_APPLE) trptype (tcp)
    AMQ8014: WebSphere MQ channel created.
    end
    2 : end
    One MQSC command read.
    No commands have a syntax error.
    All valid MQSC commands were processed.


    [mqm@websphere2 ~]$ runmqsc QM_ORANGE
    5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED.
    Starting MQSC for queue manager QM_ORANGE.


    start channel (QM_ORANGE.QM_APPLE)
    1 : start channel (QM_ORANGE.QM_APPLE)
    AMQ8018: Start WebSphere MQ channel accepted.
    end
    2 : end
    One MQSC command read.
    No commands have a syntax error.
    All valid MQSC commands were processed.

    You have now created all the WebSphere MQ objects required for messages to be sent from the sending queue manager QM_ORANGE to the queue Q1 on the receiving queue manager QM_APPLE. The next task is to send a test message.

    --------------------------------------------------------------------------------------------
    Putting a test message onto the queue using MQSC

    Go to websphere2.fedora.com

    Perform this task on the sending machine (the machine that hosts the queue manager QM_ORANGE.

    The amqsput sample program is used to put a message onto 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.

    Open a command prompt and follow these steps:

    1. Start the amqsput sample program as follows:

    • On Linux, change to the /opt/mqm/samp/bin directory and type the command: ./amqsput Q1
    • On Windows, type the command: amqsput Q1

    The following messages are displayed:


    [mqm@websphere2 ~]$ cd /opt/mqm/samp/bin/
    [mqm@websphere2 bin]$ ./amqsput Q1
    Sample AMQSPUT0 start
    target queue is Q1
    This is my message I am sending from webspohere2.fedora6.com

    2. Type some message text on one or more lines, then press Enter twice. The following message is displayed:

    Sample amqsput0 end


    Sample AMQSPUT0 end
    [mqm@websphere2 bin]$

    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.

    runmqlsr -m QM_ORANGE -t TCP -p 60000 -i 192.168.0.65 &

    ----------------------------------------------------------------------------------------------------
    Verifying that the test message was sent using MQSC

    You perform this task on the receiving machine (the machine that hosts the queue manager QM_APPLE). The amqsget sample program is used to get the message back from the queue.

    Open a command prompt and follow these steps:

    Start the amqsget sample program as follows:

    • On Linux, change to the /opt/mqm/samp/bin directory and type the command: ./amqsget Q1
    • On Windows, type the command: amqsget Q1
    -bash-3.1$ /opt/mqm/samp/bin/amqsget Q1
    Sample AMQSGET0 start
    MQCONN ended with reason code 2059

    The sample program starts, and your message is displayed along with any other messages on this queue. After a short pause, the sample program ends and the command prompt is displayed again.

Get my WebSphere MQ course here >> http://www.themiddlewareshop.com/products/

Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories