Class RouterSpec<K,R extends AbstractMappingMessageRouter>
java.lang.Object
org.springframework.integration.dsl.IntegrationComponentSpec<S,reactor.util.function.Tuple2<F,H>>
org.springframework.integration.dsl.EndpointSpec<S,ConsumerEndpointFactoryBean,H>
org.springframework.integration.dsl.ConsumerEndpointSpec<S,R>
org.springframework.integration.dsl.AbstractRouterSpec<RouterSpec<K,R>,R>
org.springframework.integration.dsl.RouterSpec<K,R>
- Type Parameters:
K
- the key type.R
- theAbstractMappingMessageRouter
implementation type.
- All Implemented Interfaces:
DisposableBean
,FactoryBean<reactor.util.function.Tuple2<ConsumerEndpointFactoryBean,
,R>> InitializingBean
,Lifecycle
,Phased
,SmartLifecycle
,ComponentsRegistration
public class RouterSpec<K,R extends AbstractMappingMessageRouter>
extends AbstractRouterSpec<RouterSpec<K,R>,R>
The
AbstractRouterSpec
for an AbstractMappingMessageRouter
.- Since:
- 5.0
- Author:
- Artem Bilan, Gary Russell
-
Field Summary
Fields inherited from class org.springframework.integration.dsl.ConsumerEndpointSpec
adviceChain
Fields inherited from class org.springframework.integration.dsl.EndpointSpec
componentsToRegister, endpointFactoryBean, handler
Fields inherited from class org.springframework.integration.dsl.IntegrationComponentSpec
logger, PARSER, target
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRouterSpec<K,
R> channelKeyFallback
(boolean channelKeyFallback) When true (default), if a resolved channel key does not exist in the channel map, the key itself is used as the channel name, which we will attempt to resolve to a channel.RouterSpec<K,
R> channelMapping
(K key, String channelName) RouterSpec<K,
R> channelMapping
(K key, MessageChannel channel) The router mapping configuration based on the provided generic key andMessageChannel
bean.RouterSpec<K,
R> Make a default output mapping of the router to the parent flow.RouterSpec<K,
R> dynamicChannelLimit
(int dynamicChannelLimit) Set a limit for how many dynamic channels are retained (for reporting purposes).RouterSpec<K,
R> Deprecated, for removal: This API element is subject to removal in a future version.RouterSpec<K,
R> Cannot be invoked ifsubFlowMapping(Object, IntegrationFlow)
is used.RouterSpec<K,
R> resolutionRequired
(boolean resolutionRequired) RouterSpec<K,
R> subFlowMapping
(K key, IntegrationFlow subFlow) Add a subflow as an alternative to achannelMapping(Object, String)
.RouterSpec<K,
R> Cannot be invoked ifsubFlowMapping(Object, IntegrationFlow)
is used.Methods inherited from class org.springframework.integration.dsl.AbstractRouterSpec
applySequence, defaultOutputChannel, defaultOutputChannel, defaultSubFlowMapping, ignoreSendFailures, isDefaultToParentFlow
Methods inherited from class org.springframework.integration.dsl.ConsumerEndpointSpec
advice, async, autoStartup, customizeMonoReply, doGet, handleMessageAdvice, notPropagatedHeaders, order, phase, poller, reactive, reactive, requiresReply, role, sendTimeout, taskScheduler, transactional, transactional, transactional, transactional, transactional
Methods inherited from class org.springframework.integration.dsl.EndpointSpec
assertHandler, id, obtainInputChannelFromFlow, obtainInputChannelFromFlow, poller, poller
Methods inherited from class org.springframework.integration.dsl.IntegrationComponentSpec
_this, afterPropertiesSet, destroy, get, getId, getObject, getObjectType, getPhase, isAutoStartup, isRunning, start, stop, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.beans.factory.FactoryBean
isSingleton
-
Constructor Details
-
RouterSpec
-
-
Method Details
-
resolutionRequired
- Parameters:
resolutionRequired
- the resolutionRequired.- Returns:
- the router spec.
- See Also:
-
dynamicChannelLimit
Set a limit for how many dynamic channels are retained (for reporting purposes). When the limit is exceeded, the oldest channel is discarded.NOTE: this does not affect routing, just the reporting which dynamically resolved channels have been routed to. Default
100
.- Parameters:
dynamicChannelLimit
- the limit.- Returns:
- the router spec.
- See Also:
-
prefix
Cannot be invoked ifsubFlowMapping(Object, IntegrationFlow)
is used.- Parameters:
prefix
- the prefix.- Returns:
- the router spec.
- See Also:
-
suffix
Cannot be invoked ifsubFlowMapping(Object, IntegrationFlow)
is used.- Parameters:
suffix
- the suffix to set.- Returns:
- the router spec.
- See Also:
-
noChannelKeyFallback
Deprecated, for removal: This API element is subject to removal in a future version.since 6.0 in favor ofchannelKeyFallback(boolean)
By default, if a resolved channel key does not exist in the channel map, the key itself is used as the channel name, which we will attempt to resolve to a channel. Invoke this method to disable this feature. This could be useful to prevent malicious actors from generating a message that could cause the message to be routed to an unexpected channel, such as one upstream of the router, which would cause a stack overflow.- Returns:
- the router spec.
- Since:
- 5.2
-
channelKeyFallback
When true (default), if a resolved channel key does not exist in the channel map, the key itself is used as the channel name, which we will attempt to resolve to a channel. Set tofalse
to disable this feature.- Parameters:
channelKeyFallback
- false to disable the fallback.- Returns:
- the router spec.
- Since:
- 6.0
- See Also:
-
channelMapping
- Parameters:
key
- the key.channelName
- the channelName.- Returns:
- the router spec.
- See Also:
-
channelMapping
The router mapping configuration based on the provided generic key andMessageChannel
bean. TheMessageChannel
must be instance ofNamedComponent
for proper target router mapping based on the bean name.- Parameters:
key
- the key.channel
- theMessageChannel
instance to use.- Returns:
- the router spec.
- Since:
- 5.2
- See Also:
-
subFlowMapping
Add a subflow as an alternative to achannelMapping(Object, String)
.prefix(String)
andsuffix(String)
cannot be used when subflow mappings are used.If subflow should refer to the external
IntegrationFlow
bean and there is a requirement to expect reply from there, such a reference should be wrapped with a.gateway()
:.subFlowMapping(false, sf -> sf.gateway(evenFlow())))
- Parameters:
key
- the key.subFlow
- the subFlow.- Returns:
- the router spec.
-
defaultOutputToParentFlow
Make a default output mapping of the router to the parent flow. Use the next, after router, parent flowMessageChannel
as aAbstractMessageRouter.setDefaultOutputChannel(MessageChannel)
of this router. This option also disablesAbstractMappingMessageRouter.setChannelKeyFallback(boolean)
, if not called explicitly afterwards, to skip an attempt to resolve the channel name.- Overrides:
defaultOutputToParentFlow
in classAbstractRouterSpec<RouterSpec<K,
R extends AbstractMappingMessageRouter>, R extends AbstractMappingMessageRouter> - Returns:
- the router spec.
- Since:
- 6.0
-
getComponentsToRegister
- Specified by:
getComponentsToRegister
in interfaceComponentsRegistration
- Overrides:
getComponentsToRegister
in classEndpointSpec<RouterSpec<K,
R extends AbstractMappingMessageRouter>, ConsumerEndpointFactoryBean, R extends AbstractMappingMessageRouter>
-
channelKeyFallback(boolean)