Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem putting msg on Remote Queue of Websphere MQ

Posted on 2008-10-06
3
Medium Priority
?
3,150 Views
Last Modified: 2013-12-17
Hi,

I have been assigned a task to upload files to a Websphere MQ. I have no background of MQ before.
1.  I installed the MQ server in my XP machine.
2. Two Queue Manager is created in my machine.
3. There are few local & remote queue created.
4. I can put test messages in QM1 & I can see the same message in QM2 when I browse message in QM2.
5. Now I am trying to run the sample program to connect the queue programatically.
6. The MQ is configured with One local Queue, One Transmission Queue, two Remote Queue.

My attached code snippet is working when accessing the local queue but cannot access the local queue.

Ok now I have tried the following to access the remote queue but with no success

MQQueue system_default_local_queue = qMgr.AccessQueue("FormatName:Direct=TCP:127.0.0.1(1516)\\msmq\\Private$\\Q.EZL01.SEP.CMCC.001.S1", openOptions);


Please help me. I am very confused about the parameter I am passing to the above program.

Thanks in advance
using System;
using IBM.WMQ;
 
public class MQSample1
{
    private String qManager = "QMQB01"; //define name of queue
    //manager to connect to.
    private MQQueueManager qMgr;  //define a queue manager object
 
    static void Main(string[] args)
    {
        new MQSample1();
    }
    public MQSample1()
    {
        try
        {
 
 
 
            //Create a connection to the queue manager
            qMgr = new MQQueueManager(qManager);
 
            //Set up the options on the queue we wish to open...
            //Note.All WebSphere MQ Options are prefixed with MQC
            int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
 
            //Now specify the queue that we wish to open,
            //and the open options...
            MQQueue system_default_local_queue = qMgr.AccessQueue("Q.QB01.SEP.MAQS.002.S1", openOptions);
            
            //Define a simple WebSphere MQ message,and write some text in UTF format..
            MQMessage hello_world = new MQMessage();
            hello_world.WriteUTF("Hello World!");
 
            //specify the message options...
            MQPutMessageOptions pmo = new MQPutMessageOptions(); //accept the defaults,
 
            //same as MQPMO_DEFAULT
            //put the message on the queue
            system_default_local_queue.Put(hello_world, pmo);
 
            //get the message back again...
            //First define a WebSphere MQ message buffer to receive the message into..
            MQMessage retrievedMessage = new MQMessage();
            retrievedMessage.MessageId = hello_world.MessageId;
            
            //Set the get message options...
            MQGetMessageOptions gmo = new MQGetMessageOptions(); //accept the defaults
            //same as MQGMO_DEFAULT
 
            //get the message off the queue...
            system_default_local_queue.Get(retrievedMessage, gmo);
            //And prove we have the message by displaying the UTF message text
            String msgText = retrievedMessage.ReadUTF();
            Console.WriteLine("The message is:" + msgText);
            //Close the queue...
            system_default_local_queue.Close();
            //Disconnect from the queue manager
            qMgr.Disconnect();
        }
        //If an error has occurred in the above,try to identify what went wrong
 
        //Was it a WebSphere MQ error?
        catch (MQException ex)
        {
            Console.WriteLine("A WebSphere MQ error occurred :Completion code " +
            ex.CompletionCode + "Reason code " + ex.ReasonCode);
        }
        //Was it a System error?
        catch (System.Exception ex)
        {
            Console.WriteLine("A System error occurred:" + ex);
        }
    }
}

Open in new window

0
Comment
Question by:kakali
  • 2
3 Comments
 
LVL 5

Expert Comment

by:lgacs
ID: 22657647
MQ allows you to put messages both local and remote queue.
You can GET message ONLY from local queue.
0
 

Author Comment

by:kakali
ID: 22657660
Thanks for your answer.....infact I want to put message. When I set breakpoint at the line number:30 which is access queue method call I get exception reason code 2059 if I mention remote queue name.
0
 

Accepted Solution

by:
kakali earned 0 total points
ID: 22657736
Ok, I myself could solve the problem.

For the remote queue the openOption cannot be "MQC.MQOO_INPUT_AS_Q_DEF "

 
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question