Advertisement
| 10.06.2008 at 09:13PM PDT, ID: 23792669 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: |
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);
}
}
}
|
Advertisement