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<org.springframework.messaging.Message<?>>,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.core.Ordered,ExpressionCapable,Orderable,IntegrationPattern,MessageRouter,NamedComponent,IntegrationManagement,TrackableComponent,org.springframework.messaging.MessageHandler,reactor.core.CoreSubscriber<org.springframework.messaging.Message<?>>
- Direct Known Subclasses:
AbstractMappingMessageRouter,RecipientListRouter
@ManagedResource @IntegrationManagedResource public abstract class AbstractMessageRouter extends AbstractMessageHandler implements MessageRouter
Base class for all Message Routers.
-
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_NAME -
Constructor Summary
Constructors Constructor Description AbstractMessageRouter() -
Method Summary
Modifier and Type Method Description protected abstract java.util.Collection<org.springframework.messaging.MessageChannel>determineTargetChannels(org.springframework.messaging.Message<?> message)Subclasses must implement this method to return a Collection of zero or more MessageChannels to which the given Message should be routed.java.lang.StringgetComponentType()Subclasses may implement this method to provide component type information.org.springframework.messaging.MessageChannelgetDefaultOutputChannel()Get the default output channel.IntegrationPatternTypegetIntegrationPatternType()Return a pattern type this component implements.protected MessagingTemplategetMessagingTemplate()ProvidesMessagingTemplateaccess for subclassesprotected org.springframework.core.convert.ConversionServicegetRequiredConversionService()protected voidhandleMessageInternal(org.springframework.messaging.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(org.springframework.messaging.MessageChannel defaultOutputChannel)Set the default channel where Messages should be sent if channel resolution fails to return any channels.voidsetDefaultOutputChannelName(java.lang.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 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
public void setDefaultOutputChannel(org.springframework.messaging.MessageChannel defaultOutputChannel)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
public org.springframework.messaging.MessageChannel getDefaultOutputChannel()Get the default output channel.- Specified by:
getDefaultOutputChannelin interfaceMessageRouter- Returns:
- the channel.
- Since:
- 4.3
-
setDefaultOutputChannelName
public void setDefaultOutputChannelName(java.lang.String defaultOutputChannelName) -
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
public java.lang.String 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
ProvidesMessagingTemplateaccess for subclasses- Returns:
- The messaging template.
-
getRequiredConversionService
protected org.springframework.core.convert.ConversionService getRequiredConversionService() -
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classIntegrationObjectSupport
-
determineTargetChannels
protected abstract java.util.Collection<org.springframework.messaging.MessageChannel> determineTargetChannels(org.springframework.messaging.Message<?> message)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
protected void handleMessageInternal(org.springframework.messaging.Message<?> message)- Specified by:
handleMessageInternalin classAbstractMessageHandler
-