de.otto.synapse.endpoint.MessageInterceptor 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;
import de.otto.synapse.message.TextMessage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Message interceptors are used to intercept messages before they are sent or received by
* {@link AbstractMessageEndpoint message endpoints}.
*
*
* MessageInterceptors will usually be chained using a {@link InterceptorChain}.
*
*
* A {@code MessageInterceptor} can be used in different ways like, for example:
*
*
* - Logging
* - Calculating Metrics
* - Wire Taps
* - {@link MessageFilter Message Filters}
*
*
* ...and many other.
*
*
*
*
*
* @see EIP: Message Filter
* @see EIP: Wire Taps
*/
@FunctionalInterface
public interface MessageInterceptor {
/**
* Intercept a message and return the same message, a modified version of the incoming message, or null, if
* the message should be filtered out and dropped by the {@link AbstractMessageEndpoint}
*
* @param message the channel-layer message with payload-type beeing a String
* @return intercepted version of the message, or null if the message should be dropped.
*/
@Nullable
TextMessage intercept(final @Nonnull TextMessage message);
}