public abstract class MessageEndpoint
extends java.lang.Object
The MessageEndpoint class is intended to derive message sender,
message receiver or
message-log receiver endpoints.
Message Endpoint code is custom to both the application and the messaging system’s client API. The rest of the application knows little about message formats, messaging channels, or any of the other details of communicating with other applications via messaging. It just knows that it has a request or piece of data to send to another application, or is expecting those from another application.
It is the messaging endpoint code that takes that command or data, makes it into a message, and sends it on a particular messaging channel. It is the endpoint that receives a message, extracts the contents, and gives them to the application in a meaningful way.
| Constructor and Description |
|---|
MessageEndpoint(java.lang.String channelName)
Constructor used to create a new AbstractMessageEndpoint.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getChannelName()
Returns the name of the channel.
|
protected abstract EndpointType |
getEndpointType() |
InterceptorChain |
getInterceptorChain()
Returns the
InterceptorChain of the MessageEndpoint. |
protected Message<java.lang.String> |
intercept(Message<java.lang.String> message)
Intercepts a message using all registered interceptors and returns the resulting message.
|
void |
registerInterceptorsFrom(MessageInterceptorRegistry registry)
Registers all
MessageInterceptor from the registry that is matching
the channelName and getEndpointType(). |
public MessageEndpoint(@Nonnull
java.lang.String channelName)
channelName - the name of the underlying channel / stream / queue / message log.@Nonnull public final java.lang.String getChannelName()
The channel name corresponds to the name of the underlying stream, queue or message log.
public final InterceptorChain getInterceptorChain()
InterceptorChain of the MessageEndpoint.public final void registerInterceptorsFrom(@Nonnull
MessageInterceptorRegistry registry)
MessageInterceptor from the registry that is matching
the channelName and getEndpointType().
The registered interceptors will be used to intercept messages processed by the endpoint.
registry - the MessageInterceptorRegistryprotected abstract EndpointType getEndpointType()
@Nullable protected final Message<java.lang.String> intercept(@Nonnull Message<java.lang.String> message)
The interceptors are called in order. The result of one interceptor is propagated to the next interceptor in the chain, until the end of the chain is reached, or one interceptor has returned null.
If null is returned, the message must be dropped by the MessageEndpoint.
Every interceptor may transform the message, or may take additional actions like, for example, logging, monitoring or other things.
message - the message to intercept