IMessageReceiver

Callback interface to receive incoming messages.

Description

The IMessageReceive interface is used to receive incoming messages.

Instance methods

receiveMessage

Receives an incoming message from the queue.

See also MessageEnvelope, IMessageQueue

Task ReceiveMessageAsync(MessageEnvelope envelope, IMessageQueue queue)

Examples

class MyMessageReceiver: IMessageReceiver 
{
    public void ReceiveMessage(MessageEnvelop envelop, IMessageQueue queue)
    {
        Console.Out.WriteLine("Received message: " + envelop.getMessageAsString());
        ...
    }
}

var messageQueue = new MemoryMessageQueue();

Task.Run(() => messageQueue.ListenAsync("123", new MyMessageReceiver()));

await messageQueue.OpenAsync("123");
await messageQueue.SendAsync("123", new MessageEnvelope(null, "mymessage", "ABC")); // Output in console: "ABC"

Thread.Sleep(500);

await messageQueue.CloseAsync("123");