Class AbstractMessageRouter
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.router.AbstractMessageRouter
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>,Aware,BeanFactoryAware,BeanNameAware,DisposableBean,InitializingBean,ApplicationContextAware,Ordered,ExpressionCapable,Orderable,IntegrationPattern,MessageRouter,NamedComponent,IntegrationManagement,TrackableComponent,MessageHandler,reactor.core.CoreSubscriber<Message<?>>
- Direct Known Subclasses:
AbstractMappingMessageRouter,RecipientListRouter
@ManagedResource
@IntegrationManagedResource
public abstract class AbstractMessageRouter
extends AbstractMessageHandler
implements MessageRouter
Base class for all Message Routers.
- Author:
- Mark Fisher, Oleg Zhurakousky, Gunnar Hillert, Soby Chacko, Stefan Ferstl, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields 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 abstract Collection<MessageChannel>determineTargetChannels(Message<?> message) Subclasses must implement this method to return a Collection of zero or more MessageChannels to which the given Message should be routed.Subclasses may implement this method to provide component type information.Get the default output channel.Return a pattern type this component implements.protected MessagingTemplateProvideMessagingTemplateaccess for subclasses.protected ConversionServiceprotected voidhandleMessageInternal(Message<?> message) protected voidonInit()Subclasses may implement this for initialization logic.voidsetApplySequence(boolean applySequence) Specify whether to apply the sequence number and size headers to the messages prior to sending to the recipient channels.voidsetDefaultOutputChannel(MessageChannel defaultOutputChannel) Set the default channel where Messages should be sent if channel resolution fails to return any channels.voidsetDefaultOutputChannelName(String defaultOutputChannelName) voidsetIgnoreSendFailures(boolean ignoreSendFailures) Specify whether send failures for one or more of the recipients should be ignored.voidsetSendTimeout(long timeout) Set the timeout for sending a message to the resolved channel.Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribeMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods 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, 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.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
AbstractMessageRouter
public AbstractMessageRouter()
-
-
Method Details
-
setDefaultOutputChannel
Set the default channel where Messages should be sent if channel resolution fails to return any channels. If no default channel is provided and channel resolution fails to return any channels, the router will throw anMessageDeliveryException.If messages shall be ignored (dropped) instead, please provide a
NullChannel.- Parameters:
defaultOutputChannel- The default output channel.
-
getDefaultOutputChannel
Get the default output channel.- Specified by:
getDefaultOutputChannelin interfaceMessageRouter- Returns:
- the channel.
- Since:
- 4.3
-
setDefaultOutputChannelName
-
setSendTimeout
public void setSendTimeout(long timeout) Set the timeout for sending a message to the resolved channel. By default, there is no timeout, meaning the send will block indefinitely.- Parameters:
timeout- The timeout.- Since:
- 4.3
-
setIgnoreSendFailures
public void setIgnoreSendFailures(boolean ignoreSendFailures) Specify whether send failures for one or more of the recipients should be ignored. By default this isfalsemeaning that an Exception will be thrown whenever a send fails. To override this and suppress Exceptions, set the value totrue.- Parameters:
ignoreSendFailures- true to ignore send failures.
-
setApplySequence
public void setApplySequence(boolean applySequence) Specify whether to apply the sequence number and size headers to the messages prior to sending to the recipient channels. By default, this value isfalsemeaning that sequence headers will not be applied. If planning to use an Aggregator downstream with the default correlation and completion strategies, you should set this flag totrue.- Parameters:
applySequence- true to apply sequence information.
-
getComponentType
Description copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageHandlerSupport
-
getIntegrationPatternType
Description copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
getIntegrationPatternTypein interfaceIntegrationPattern- Overrides:
getIntegrationPatternTypein classMessageHandlerSupport- Returns:
- the
IntegrationPatternTypethis component implements.
-
getMessagingTemplate
ProvideMessagingTemplateaccess for subclasses.- Returns:
- The messaging template.
-
getRequiredConversionService
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classIntegrationObjectSupport
-
determineTargetChannels
Subclasses must implement this method to return a Collection of zero or more MessageChannels to which the given Message should be routed.- Parameters:
message- The message.- Returns:
- The collection of message channels.
-
handleMessageInternal
- Specified by:
handleMessageInternalin classAbstractMessageHandler
-