Class AbstractMessageSplitter
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.splitter.AbstractMessageSplitter
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Ordered
,ExpressionCapable
,Orderable
,MessageProducer
,DiscardingMessageHandler
,HeaderPropagationAware
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageHandler
,reactor.core.CoreSubscriber<Message<?>>
- Direct Known Subclasses:
DefaultMessageSplitter
,ExpressionEvaluatingSplitter
,FileSplitter
,MethodInvokingSplitter
,XPathMessageSplitter
public abstract class AbstractMessageSplitter extends AbstractReplyProducingMessageHandler implements DiscardingMessageHandler
Base class for Message-splitting handlers.
- Author:
- Mark Fisher, Dave Syer, Artem Bilan, Ruslan Stelmachenko, Gary Russell
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandler
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
messagingTemplate
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors Constructor Description AbstractMessageSplitter()
-
Method Summary
Modifier and Type Method 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 providedIterable
.protected int
obtainSizeIfPossible(Iterator<?> iterator)
Obtain a size of the providedIterator
.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 toMessageChannel
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.Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
doInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply
Methods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldSplitOutput, updateNotPropagatedHeaders
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
AbstractMessageSplitter
public AbstractMessageSplitter()
-
-
Method Details
-
setApplySequence
public void setApplySequence(boolean applySequence)Set the applySequence flag to the specified value. Defaults to true.- Parameters:
applySequence
- true to apply sequence information.
-
setDiscardChannel
Specify a channel 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.- Parameters:
discardChannel
- The discard channel.- Since:
- 5.2
-
setDiscardChannelName
Specify a channel bean name (resolved toMessageChannel
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.- Parameters:
discardChannelName
- The discard channel bean name.- Since:
- 5.2
-
getDiscardChannel
Description copied from interface:DiscardingMessageHandler
Return the discard channel.- Specified by:
getDiscardChannel
in interfaceDiscardingMessageHandler
- Returns:
- the channel.
-
getIntegrationPatternType
Description copied from interface:IntegrationPattern
Return a pattern type this component implements.- Specified by:
getIntegrationPatternType
in interfaceIntegrationPattern
- Overrides:
getIntegrationPatternType
in classAbstractReplyProducingMessageHandler
- Returns:
- the
IntegrationPatternType
this component implements.
-
doInit
protected void doInit()- Overrides:
doInit
in classAbstractReplyProducingMessageHandler
-
handleRequestMessage
Description copied from class:AbstractReplyProducingMessageHandler
Subclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.- Specified by:
handleRequestMessage
in classAbstractReplyProducingMessageHandler
- Parameters:
message
- The request message.- Returns:
- The result of handling the message, or
null
.
-
obtainSizeIfPossible
Obtain a size of the providedIterable
. Default implementation returnsCollection.size()
if the iterable is a collection, or0
otherwise. If iterable is a JacksonTreeNode
, then its size is used. -
obtainSizeIfPossible
Obtain a size of the providedIterator
. Default implementation returns0
. -
willAddHeaders
Return true if the subclass needs to add headers in the resulting splits. If true,addHeaders(org.springframework.messaging.Message<?>, java.util.Map<java.lang.String, java.lang.Object>)
will be called.- Parameters:
message
- the message.- Returns:
- true
-
addHeaders
Allows subclasses to add extra headers to the output messages. Headers may not be removed by this method.- Parameters:
message
- the inbound message.headers
- the headers to add messages to.
-
shouldCopyRequestHeaders
protected boolean shouldCopyRequestHeaders()Description copied from class:AbstractMessageProducingHandler
Subclasses may override this. True by default.- Overrides:
shouldCopyRequestHeaders
in classAbstractMessageProducingHandler
- Returns:
- true if the request headers should be copied.
-
produceOutput
- Overrides:
produceOutput
in classAbstractMessageProducingHandler
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessageHandlerSupport
-
splitMessage
Subclasses must override this method to split the received Message. The return value may be a Collection or Array. The individual elements may be Messages, but it is not necessary. If the elements are not Messages, each will be provided as the payload of a Message. It is also acceptable to return a single Object or Message. In that case, a single reply Message will be produced.- Parameters:
message
- The message.- Returns:
- The result of splitting the message.
-