IMessageReceive

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

receiveMessage(envelope: MessageEnvelope, queue: IMessageQueue): Promise<void>

Examples

class MyMessageReceiver implements IMessageReceiver {
  public async receiveMessage(envelop: MessageEnvelop, queue: IMessageQueue): Promise<void> {
      console.log("Received message: " + envelop.getMessageAsString());
  }
}
let messageQueue = new MemoryMessageQueue();
messageQueue.listen("123", new MyMessageReceiver());
await messageQueue.open("123")
await messageQueue.send("123", new MessageEnvelop(null, "mymessage", "ABC")); // Output in console: "ABC"