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, 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
-
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 MessagingTemplate
ProvideMessagingTemplate
access for subclasses.protected ConversionService
protected void
handleMessageInternal
(Message<?> message) protected void
onInit()
Subclasses may implement this for initialization logic.void
setApplySequence
(boolean applySequence) Specify whether to apply the sequence number and size headers to the messages prior to sending to the recipient channels.void
setDefaultOutputChannel
(MessageChannel defaultOutputChannel) Set the default channel where Messages should be sent if channel resolution fails to return any channels.void
setDefaultOutputChannelName
(String defaultOutputChannelName) void
setIgnoreSendFailures
(boolean ignoreSendFailures) Specify whether send failures for one or more of the recipients should be ignored.void
setSendTimeout
(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, onSubscribe, setObservationConvention
Methods 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, 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 reactor.core.CoreSubscriber
currentContext
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
-
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:
getDefaultOutputChannel
in 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 isfalse
meaning 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 isfalse
meaning 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:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessageHandlerSupport
-
getIntegrationPatternType
Description copied from interface:IntegrationPattern
Return a pattern type this component implements.- Specified by:
getIntegrationPatternType
in interfaceIntegrationPattern
- Overrides:
getIntegrationPatternType
in classMessageHandlerSupport
- Returns:
- the
IntegrationPatternType
this component implements.
-
getMessagingTemplate
ProvideMessagingTemplate
access for subclasses.- Returns:
- The messaging template.
-
getRequiredConversionService
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in 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:
handleMessageInternal
in classAbstractMessageHandler
-