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, Christian Tzolov
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, 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.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
AbstractMessageRouterpublic AbstractMessageRouter()
 
- 
- 
Method Details- 
setDefaultOutputChannelSet 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.
 
- 
getDefaultOutputChannelGet the default output channel.- Specified by:
- getDefaultOutputChannelin interface- MessageRouter
- Returns:
- the channel.
- Since:
- 4.3
 
- 
setDefaultOutputChannelName
- 
setSendTimeoutpublic void setSendTimeout(long timeout) Set the timeout for sending a message to the resolved channel. By default, 30 seconds timeout.- Parameters:
- timeout- The timeout.
- Since:
- 4.3
 
- 
setIgnoreSendFailurespublic 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.
 
- 
setApplySequencepublic 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.
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- MessageHandlerSupport
 
- 
getIntegrationPatternTypeDescription copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
- getIntegrationPatternTypein interface- IntegrationPattern
- Overrides:
- getIntegrationPatternTypein class- MessageHandlerSupport
- Returns:
- the IntegrationPatternTypethis component implements.
 
- 
getMessagingTemplateProvideMessagingTemplateaccess for subclasses.- Returns:
- The messaging template.
 
- 
getRequiredConversionService
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- IntegrationObjectSupport
 
- 
determineTargetChannelsSubclasses 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 class- AbstractMessageHandler
 
 
-