|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQRC_UNEXPECTED_ERROR |
« View previous topic :: View next topic » |
Author |
Message
|
Harimar |
Posted: Tue Sep 15, 2009 2:27 am Post subject: MQRC_UNEXPECTED_ERROR |
|
|
Newbie
Joined: 15 Sep 2009 Posts: 1
|
Hi,
I have written a basic put message and get message C# code to put and get message from a Local Queue.
I don't have problem accessing the queue and putting the message to the queue. When i try to read the message, i get the MQRC_UNEXPECTED_ERROR Reason code 2195. Can someone please help me to fix this issue.
I have amqmdnet.dll version 1.0.0.3 referenced in my code.
My code sample :
Code: |
using System;
using IBM.WMQ;
namespace MQSeries
{
class MQSeriesClass
{
MQQueueManager queueManager;
MQQueue queue;
MQMessage queueMessage;
MQPutMessageOptions queuePutMessageOptions;
MQGetMessageOptions queueGetMessageOptions;
static string QueueName;
static string QueueManagerName;
static string ChannelInfo;
string channelName;
string transportType;
string connectionName;
string message;
byte[] MessageID;
static void Main(string[] args)
{
Console.WriteLine("Enter the Queue Name : ");
QueueName = Console.ReadLine();
Console.WriteLine("Enter the Queue Manager Name : ");
QueueManagerName = Console.ReadLine();
Console.WriteLine("Enter the Channel Info, Format: ChannelName/TCP/192.168.232.500 ");
ChannelInfo = Console.ReadLine();
MQSeriesClass mqSeries = new MQSeriesClass();
mqSeries.putTheMessageIntoQueue();
mqSeries.GetMessageFromTheQueue();
Console.ReadLine();
}
public void putTheMessageIntoQueue()
{
char[] separator = { '/' };
string[] ChannelParams;
ChannelParams = ChannelInfo.Split(separator);
channelName = ChannelParams[0];
transportType = ChannelParams[1];
connectionName = ChannelParams[2];
try
{
queueManager = new MQQueueManager(QueueManagerName, channelName, connectionName);
queue = queueManager.AccessQueue(QueueName, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
Console.WriteLine("Enter the message to put in MQSeries server:");
message = System.Console.ReadLine();
int msgLen = message.Length;
while (msgLen == 0)
{
if (msgLen == 0)
Console.WriteLine("Please reenter the message:");
message = System.Console.ReadLine();
msgLen = message.Length;
}
queueMessage = new MQMessage();
queueMessage.WriteString(message);
queueMessage.Format = MQC.MQFMT_STRING;
queuePutMessageOptions = new MQPutMessageOptions();
//putting the message into the queue
queue.Put(queueMessage, queuePutMessageOptions);
//MessageID = queueMessage.MessageId;
Console.WriteLine("Success fully entered the message into the queue");
}
catch (MQException mqexp)
{
Console.WriteLine("MQSeries Exception: " + mqexp.Message);
}
}
public void GetMessageFromTheQueue()
{
queue = queueManager.AccessQueue(QueueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
queueMessage = new MQMessage();
queueMessage.Format = MQC.MQFMT_STRING;
//queueMessage.MessageId = MessageID;
queueGetMessageOptions = new MQGetMessageOptions();
try
{
queue.Get(queueMessage, queueGetMessageOptions);
// Received Message.
System.Console.WriteLine("Received Message: {0}", queueMessage.ReadString(queueMessage.MessageLength));
}
catch (MQException MQExp)
{
// report the error
System.Console.WriteLine("MQQueue::Get ended with " + MQExp.Message);
}
}
}
} |
Thanks in advance
-Hariharan |
|
Back to top |
|
 |
Vitor |
Posted: Tue Sep 15, 2009 7:22 am Post subject: Re: MQRC_UNEXPECTED_ERROR |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Harimar wrote: |
When i try to read the message, i get the MQRC_UNEXPECTED_ERROR Reason code 2195. Can someone please help me to fix this issue. |
There will be an FDC file that corresponds with that error (which shouldn't happen no matter what your code does). Look up the ProbeId in that file and respond accordingly. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Sep 15, 2009 9:15 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
Some of the early releases of WMQ with dotnet support are very buggy. You should apply the latest FixPack (CSD) to your WMQ installation.
Secondly, make sure you "close" objects when you done with them. Do NOT rely on MQ (or dotnet) to automatically close those objects. (i.e. queue and the queue manager objects).
From looking at your code, the only thing that comes to mind, is that the second open is for the same queue but different options. Hence, close the queue in the putTheMessageIntoQueue mathod then when you open it in the GetMessageFromTheQueue method, everything should be fine.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|