org.pipservices4.messaging.queues.CallbackMessageReceiver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pip-services4-messaging Show documentation
Show all versions of pip-services4-messaging Show documentation
Messaging components for Pip.Services in Java
The newest version!
package org.pipservices4.messaging.queues;
/**
* Wraps message callback into IMessageReceiver
*/
public class CallbackMessageReceiver implements IMessageReceiver {
@FunctionalInterface
private interface Callback {
void apply(MessageEnvelope envelope, IMessageQueue queue);
}
private final Callback _callback;
public CallbackMessageReceiver(Callback callback) {
if (callback == null) {
throw new Error("Callback cannot be null");
}
this._callback = callback;
}
/**
* Receives incoming message from the queue.
*
* @param envelope an incoming message
* @param queue a queue where the message comes from
* @see MessageEnvelope
* @see IMessageQueue
*/
@Override
public void receiveMessage(MessageEnvelope envelope, IMessageQueue queue) {
this._callback.apply(envelope, queue);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy