de.otto.synapse.endpoint.receiver.MessageQueueReceiverEndpoint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of synapse-core Show documentation
Show all versions of synapse-core Show documentation
A library used at otto.de to implement Spring Boot based event-sourcing microservices.
package de.otto.synapse.endpoint.receiver;
import de.otto.synapse.consumer.MessageConsumer;
import de.otto.synapse.consumer.MessageDispatcher;
import de.otto.synapse.message.Message;
import de.otto.synapse.message.TextMessage;
import java.util.concurrent.CompletableFuture;
/**
* Receiver-side {@code MessageEndpoint endpoint} of a Message Channel with Queue or FIFO semantics.
*
*
*
*
*
* {@code MessageQueueReceiverEndpoints} are Message Endpoints for Point-to-Point Channels:
*
*
*
*
*
* @see EIP: Message Endpoint
* @see EIP: Point-to-Point Channel
*/
public interface MessageQueueReceiverEndpoint extends MessageReceiverEndpoint {
/**
* Takes zero or more messages from the channel, calls {@link #intercept(TextMessage)} for every message, and notifies
* the registered consumers with the intercepted message, or drops the message, if {@code intercept} returns null.
*
*
* Consumption starts with the earliest available and not-yet-consumed message and finishes when either the
* {@code stopCondition} is met, or the application is shutting down.
*
*
* The {@link #register(MessageConsumer) registered} {@link MessageConsumer consumers} are used as a
* callback for consumed messages. A {@link MessageDispatcher} can be used as a consumer, if multiple
* consumers, or consumers with {@link Message#getPayload() message payloads} other than {@code String} are
* required.
*
* @return completable future that can be used to {@link CompletableFuture#join() wait} until the endpoint has
* stopped message consumption.
*/
CompletableFuture consume();
/**
* Stops consumption of messages and shuts down the {@code MessageQueueReceiverEndpoint}.
*/
void stop();
}