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
void receiveMessage(MessageEnvelope envelop, IMessageQueue queue)
- envelope: MessageEnvelope - incoming message
- queue: IMessageQueue - queue where the message comes from
Examples
class MyMessageReceiver implements IMessageReceiver {
public void receiveMessage(MessageEnvelope envelop, IMessageQueue queue) {
System.out.println("Received message: " + envelop.getMessageAsString());
...
}
}
MemoryMessageQueue messageQueue = new MemoryMessageQueue();
messageQueue.listen("123", new MyMessageReceiver());
messageQueue.open("123");
messageQueue.send("123", new MessageEnvelope(null, "mymessage", "ABC")); // Output in console: "ABC"
}