1

I am trying to read messages from the queue using C#. I am able to to publish the message to the queue but not able to retrieve message from the queue. Below is the sample code snippet.

Messages are already there in some queue, some one publishing messages to the queue i want to read those messages from the same queue.

using (var broker = Current.Resources.Allocate(resourceConfigUri) as IMessageSource)
{
    if (broker != null)
    {
        Message messageResponse = null;

        // now get the message
        messageResponse = broker.Receive(); // getting the exception as mentioned.

        //  SerializationUtility.ToByteArray(this);

        string messageRequestString = SerializationUtility.ToXml(messageRequest.Body);
        string messageResponseString = SerializationUtility.ToXml(messageResponse.Body);

    }
}

Here is the error:

Please define a receive (response) queue for the current resource before calling this method: resource:Tibco:Ems:Queue:EventBus.
Naveen JNK
  • 11
  • 2
  • I'm not familiar with this code so this might be misguided, but based on the documentation [here](https://azure.github.io/amqpnetlite/api/Amqp.Listener.ContainerHost.html), if you want an object that can handle **two way** communication (outgoing *and* incoming), you should use `IRequestProcessor` instead of `IMessageSource`. – Kevin Nov 12 '19 at 14:14
  • Again referencing the linked documentation, if you are only interested in *incoming* messages, the `IMessageProcessor` interface should be used. `IMessageSource` is for *outgoing* messages. – Kevin Nov 12 '19 at 15:31

0 Answers0