public abstract class AbstractMessageSplitter extends AbstractReplyProducingMessageHandler implements DiscardingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandler
IntegrationManagement.ManagementOverrides
messagingTemplate
EXPRESSION_PARSER, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Constructor and Description |
---|
AbstractMessageSplitter() |
Modifier and Type | Method and Description |
---|---|
protected void |
addHeaders(Message<?> message,
Map<String,Object> headers)
Allows subclasses to add extra headers to the output messages.
|
protected void |
doInit() |
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
MessageChannel |
getDiscardChannel()
Return the discard channel.
|
IntegrationPatternType |
getIntegrationPatternType()
Return a pattern type this component implements.
|
protected Object |
handleRequestMessage(Message<?> message)
Subclasses must implement this method to handle the request Message.
|
protected int |
obtainSizeIfPossible(Iterable<?> iterable)
Obtain a size of the provided
Iterable . |
protected int |
obtainSizeIfPossible(Iterator<?> iterator)
Obtain a size of the provided
Iterator . |
protected void |
produceOutput(Object result,
Message<?> requestMessage) |
void |
setApplySequence(boolean applySequence)
Set the applySequence flag to the specified value.
|
void |
setDiscardChannel(MessageChannel discardChannel)
Specify a channel where rejected Messages should be sent.
|
void |
setDiscardChannelName(String discardChannelName)
Specify a channel bean name (resolved to
MessageChannel lazily)
where rejected Messages should be sent. |
protected boolean |
shouldCopyRequestHeaders()
Subclasses may override this.
|
protected abstract Object |
splitMessage(Message<?> message)
Subclasses must override this method to split the received Message.
|
protected boolean |
willAddHeaders(Message<?> message)
Return true if the subclass needs to add headers in the resulting splits.
|
doInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldSplitOutput, updateNotPropagatedHeaders
handleMessage, onComplete, onError, onNext, onSubscribe
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
handleMessage
getThisAs
getBeanName, getComponentName
public void setApplySequence(boolean applySequence)
applySequence
- true to apply sequence information.public void setDiscardChannel(MessageChannel discardChannel)
discardChannel
- The discard channel.public void setDiscardChannelName(String discardChannelName)
MessageChannel
lazily)
where rejected Messages should be sent. If the discard
channel is null (the default), rejected Messages will be dropped.
A "Rejected Message" means that split function has returned an empty result (but not null):
no items to iterate for sending.discardChannelName
- The discard channel bean name.public MessageChannel getDiscardChannel()
DiscardingMessageHandler
getDiscardChannel
in interface DiscardingMessageHandler
public IntegrationPatternType getIntegrationPatternType()
IntegrationPattern
getIntegrationPatternType
in interface IntegrationPattern
getIntegrationPatternType
in class AbstractReplyProducingMessageHandler
IntegrationPatternType
this component implements.protected void doInit()
doInit
in class AbstractReplyProducingMessageHandler
protected final Object handleRequestMessage(Message<?> message)
AbstractReplyProducingMessageHandler
handleRequestMessage
in class AbstractReplyProducingMessageHandler
message
- The request message.null
.protected int obtainSizeIfPossible(Iterable<?> iterable)
Iterable
. Default implementation returns
Collection.size()
if the iterable is a collection, or 0
otherwise.
If iterable is a Jackson TreeNode
, then its size is used.protected int obtainSizeIfPossible(Iterator<?> iterator)
Iterator
.
Default implementation returns 0
.protected boolean willAddHeaders(Message<?> message)
addHeaders(org.springframework.messaging.Message<?>, java.util.Map<java.lang.String, java.lang.Object>)
will be called.message
- the message.protected void addHeaders(Message<?> message, Map<String,Object> headers)
message
- the inbound message.headers
- the headers to add messages to.protected boolean shouldCopyRequestHeaders()
AbstractMessageProducingHandler
shouldCopyRequestHeaders
in class AbstractMessageProducingHandler
protected void produceOutput(Object result, Message<?> requestMessage)
produceOutput
in class AbstractMessageProducingHandler
public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class MessageHandlerSupport
protected abstract Object splitMessage(Message<?> message)
message
- The message.