[英]Displaying messages from IBM MQ
I created application which can connect, send or read messages from queue. 我创建了可以连接,发送或读取队列中的消息的应用程序。 In this moment I want to show message (not read!) from queue.
在这一刻,我想显示队列中的消息(未读!)。 Can you help me with this issue?
您能帮我解决这个问题吗? I should use MQC.MQOO_BROWSE parameter when I try get access to queue?
当我尝试访问队列时应该使用MQC.MQOO_BROWSE参数?
I tried create method like below: 我尝试了如下创建方法:
public ShowMessage ShowMessagesFromQueue(IRequiredParameters parameters)
{
ShowMessage queue;
try
{
queue = new ShowMessage(_manager.AccessQueue(parameters.QueueName, MQC.MQOO_INQUIRE | MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_BROWSE));
Console.WriteLine("Message from queue: ");
}
catch (MQException exp)
{
Console.WriteLine(exp.Message);
throw;
}
}
and I don't know how should I implement class below: 而且我不知道如何实现以下类:
public class ShowMessage
{
private MQQueue _queue;
public ShowMessage(MQQueue queue)
{
_queue = queue;
}
public string Show()
{
var message = new MQMessage();
try
{
return message.ReadString(message.(dontKnowWhatUseHere);
}
catch (MQException exp)
{
Console.WriteLine(exp.Message);
throw;
}
}
This is good idea? 这是个好主意吗?
Ok I resolved it. 好的,我解决了。 In my Show method I had to add more option like below:
在我的Show方法中,我必须添加如下所示的更多选项:
public void Show()
{
var message = new MQMessage();
try
{
var getMessageOptions = new MQGetMessageOptions();
getMessageOptions.Options = MQC.MQGMO_BROWSE_FIRST;
_queue.Get(message, getMessageOptions);
var msg = message.ReadString(message.MessageLength);
Console.WriteLine("Preview of message: " + msg);
}
catch (MQException exp)
{
Console.WriteLine(exp.Message);
throw;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.