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,ComponentSourceAware,ExpressionCapable,Orderable,MessageProducer,DiscardingMessageHandler,HeaderPropagationAware,IntegrationPattern,NamedComponent,IntegrationManagement,TrackableComponent,MessageHandler,reactor.core.CoreSubscriber<Message<?>>
- Direct Known Subclasses:
DefaultMessageSplitter,ExpressionEvaluatingSplitter,FileSplitter,MethodInvokingSplitter,UnZipResultSplitter,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, Ngoc Nhan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
messagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddHeaders(Message<?> message, Map<String, Object> headers) Allows subclasses to add extra headers to the output messages.protected voiddoInit()Subclasses may implement this method to provide component type information.Return the discard channel.Return a pattern type this component implements.protected final ObjecthandleRequestMessage(Message<?> message) Subclasses must implement this method to handle the request Message.protected intobtainSizeIfPossible(Iterable<?> iterable) Obtain a size of the providedIterable.protected intobtainSizeIfPossible(Iterator<?> iterator) Obtain a size of the providedIterator.protected voidproduceOutput(Object result, Message<?> requestMessage) final voidsetApplySequence(boolean applySequence) Set the applySequence flag to the specified value.voidsetDiscardChannel(MessageChannel discardChannel) Specify a channel where rejected Messages should be sent.voidsetDiscardChannelName(String discardChannelName) Specify a channel bean name (resolved toMessageChannellazily) where rejected Messages should be sent.protected booleanSubclasses may override this.protected abstract ObjectsplitMessage(Message<?> message) Subclasses must override this method to split the received Message.protected booleanwillAddHeaders(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, setRequiresReplyMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscriber
currentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.messaging.MessageHandler
handleMessageMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
AbstractMessageSplitter
public AbstractMessageSplitter()
-
-
Method Details
-
setApplySequence
public final 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 toMessageChannellazily) 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:DiscardingMessageHandlerReturn the discard channel.- Specified by:
getDiscardChannelin interfaceDiscardingMessageHandler- Returns:
- the channel.
-
getIntegrationPatternType
Description copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
getIntegrationPatternTypein interfaceIntegrationPattern- Overrides:
getIntegrationPatternTypein classAbstractReplyProducingMessageHandler- Returns:
- the
IntegrationPatternTypethis component implements.
-
doInit
protected void doInit()- Overrides:
doInitin classAbstractReplyProducingMessageHandler
-
handleRequestMessage
Description copied from class:AbstractReplyProducingMessageHandlerSubclasses 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:
handleRequestMessagein 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, or0otherwise. 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:AbstractMessageProducingHandlerSubclasses may override this. True by default.- Overrides:
shouldCopyRequestHeadersin classAbstractMessageProducingHandler- Returns:
- true if the request headers should be copied.
-
produceOutput
- Overrides:
produceOutputin classAbstractMessageProducingHandler
-
getComponentType
Description copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein 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.
-