Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,
I am new to IBM MQSeries. I am trying to develop an application that passes message from an XML file to IBM queue and then read the response from the response queue, and finally display the content of the response message on some control using C#. Until now i am able to pass the message to the queue, but i have faced problem in reading the response message. The code i use is as follows and the part after e comment "//read response message from IBM Queue" generates error 2039, i have seen the description but unable to solve it. Pls forward to me your comments, Thanks!
C#
StreamReader sr = File.OpenText("\\abc.xml");
        string s =  sr.Read().ToString();
        
        MQQueueManager mqQMgr;
        try
        {
            mqQMgr = new MQQueueManager("QM_APPLE", "SYSTEM.DEF.SVRCONN", "127.0.0.1(1414)");
            MQQueue requestQueue = mqQMgr.AccessQueue("Q1",
                        MQC.MQOO_OUTPUT // open queue for output
                        + MQC.MQOO_FAIL_IF_QUIESCING); // but not if 
            // MQM stopping
            MQQueue responseQueue = mqQMgr.AccessQueue("Q2",
            MQC.MQOO_INPUT_AS_Q_DEF         // open queue for input
            + MQC.MQOO_FAIL_IF_QUIESCING);

            MQMessage requestMessage = new MQMessage();
            requestMessage.WriteString(s);
            requestMessage.Format = MQC.MQFMT_STRING;
            requestMessage.MessageType = MQC.MQMT_REQUEST;
            requestMessage.Report = MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;
            requestMessage.ReplyToQueueName = "Q2";
            requestMessage.ReplyToQueueManagerName = "MQ_APPLE";
            requestQueue.Put(requestMessage);                  


            //read response message from IBM Queue
            MQMessage responseMessage = new MQMessage();
            MQPutMessageOptions pmo = new MQPutMessageOptions();
            pmo.Options = MQC.MQPMO_NONE;
            if ((requestMessage.Report & MQC.MQRO_PASS_MSG_ID) == MQC.MQRO_PASS_MSG_ID)
                responseMessage.MessageId = requestMessage.CorrelationId;
            else                        // Assume MQRO_NEW_MSG_ID
                pmo.Options = MQC.MQPMO_NEW_MSG_ID;
            if ((requestMessage.Report & MQC.MQRO_PASS_CORREL_ID) ==
                                                   MQC.MQRO_PASS_CORREL_ID)
                responseMessage.CorrelationId = requestMessage.CorrelationId;
            else                   // Assume MQRO_COPY_MSG_ID_TO_CORREL_ID
                responseMessage.CorrelationId = requestMessage.MessageId;
            responseMessage.MessageType = MQC.MQMT_REPLY;
            
            responseMessage.WriteString("Done");
            responseQueue.Put(responseMessage);

            if (responseQueue.OpenStatus)
                responseQueue.Close();
            //if (mqQMgr.ConnectionStatus)
            //    mqQMgr.Disconnect();          
        
        }
        catch (MQException mqe)
        {
            lblMessage.Text = mqe.Reason.ToString();
            goto Wuta;
        }
Posted
Updated 25-Oct-10 2:45am
v3

1 solution

Have you seen Interfacing with IBM WebSphere[^], an article here on Code Project.

Don't know if it will help your problem but thought you might find it interesting.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900