I have a C# listener for IBM MQ like below. Only listener method mentioned here.

private void OnMessage(IMessage msg)
{
    try
    {

        ITextMessage textMsg = (ITextMessage)msg;
        Console.Write("Got a message: ");
        Console.WriteLine(textMsg.Text);

    }
    catch(Exception ex)
    {
    }
}

Whenever a text format message has been reached in side my queue, above listener is invoking and i am able to read values.

Problem is that if you stop the listener and then push a message, that message is retaining in MQ Explorer. But if the listener method has been invoked, the message has been deleting from "Web Sphere MQ Explorer" always just after read from the listener method. Do I need to set some more configuration to retain my messages even after my listener read it?

有帮助吗?

解决方案 2

That is the expected behavior. The message in a queue is being consumed by an application (meaning your OnMessage method). WebSphere MQ will deliver the message to a waiting consumer application as soon as the message arrives in queue.

If you want to messages to remain in the queue, then you need to stop all your consumer application.

其他提示

There are 2 ways to read messages from a queue:

  • destructive get (default)
  • using a non-destructive get (aka browse)

If you want to only browse messages in a queue then use the non-destructive get.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top