Annotation Type Router
@Target({METHOD,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
public @interface Router
A method annotated with @Router may accept a parameter of type
Message or of the expected
Message payload's type. Any type conversion supported by
SimpleTypeConverter will be applied to
the Message payload if necessary. Header values can also be passed as
Message parameters by using the
@Header parameter annotation.
Return values from the annotated method may be either a Collection or Array
whose elements are either
channels or
Strings. In the latter case, the endpoint hosting this router will attempt
to resolve each channel name with the Channel Registry or with
channelMappings(), if provided.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringapplySequenceSpecify whether sequence number and size headers should be added to each Message.java.lang.StringautoStartupTheSmartLifecycleautoStartupoption.java.lang.String[]channelMappingsThe 'key=value' pairs to represent channelMapping entriesjava.lang.StringdefaultOutputChannelSpecify the channel to which this router will send messages for which destination channels are not resolved andresolutionRequired()is false.java.lang.StringignoreSendFailuresIf set totrue, failures to send to a message channel will be ignored.java.lang.StringinputChannelSpecify the channel from which this router will consume messages.java.lang.StringphaseSpecify aSmartLifecyclephaseoption.Poller[]pollerjava.lang.StringprefixSpecify a prefix to be added to each channel name prior to resolution.java.lang.StringresolutionRequiredSpecify whether channel names must always be successfully resolved to existing channel instances.java.lang.StringsendTimeoutSpecify the maximum amount of time in milliseconds to wait when sending a replyMessageto theoutputChannel.java.lang.StringsuffixSpecify a suffix to be added to each channel name prior to resolution.
-
Element Details
-
inputChannel
java.lang.String inputChannelSpecify the channel from which this router will consume messages. If the channel does not exist, aDirectChannelwith this name will be registered in the application context.- Returns:
- The channel name.
- Default:
- ""
-
defaultOutputChannel
java.lang.String defaultOutputChannelSpecify the channel to which this router will send messages for which destination channels are not resolved andresolutionRequired()is false.- Returns:
- The channel name.
- Default:
- ""
-
channelMappings
java.lang.String[] channelMappingsThe 'key=value' pairs to represent channelMapping entries- Returns:
- the channelMappings.
- See Also:
AbstractMappingMessageRouter.setChannelMapping(String, String)
- Default:
- {}
-
prefix
java.lang.String prefixSpecify a prefix to be added to each channel name prior to resolution.- Returns:
- the prefix.
- Default:
- ""
-
suffix
java.lang.String suffixSpecify a suffix to be added to each channel name prior to resolution.- Returns:
- the suffix.
- Default:
- ""
-
resolutionRequired
java.lang.String resolutionRequiredSpecify whether channel names must always be successfully resolved to existing channel instances.If set to
true(default), aMessagingExceptionwill be raised in case the channel cannot be resolved. Setting this attribute tofalse, will cause any unresolvable channels to be ignored. Can be specified as 'property placeholder', e.g.${spring.integration.resolutionRequired}.- Returns:
- the resolution required flag.
- Default:
- ""
-
applySequence
java.lang.String applySequenceSpecify whether sequence number and size headers should be added to each Message. Defaults tofalse. Can be specified as 'property placeholder', e.g.${spring.integration.applySequence}.- Returns:
- the apply sequence flag.
- Default:
- ""
-
ignoreSendFailures
java.lang.String ignoreSendFailuresIf set totrue, failures to send to a message channel will be ignored. If set tofalse(default), aMessageDeliveryExceptionwill be thrown instead, and if the router resolves more than one channel, any subsequent channels will not receive the message. Please be aware that when using direct channels (single threaded), send-failures can be caused by exceptions thrown by components much further down-stream. Can be specified as 'property placeholder', e.g.${spring.integration.ignoreSendFailures}.- Returns:
- the ignore send failures flag.
- Default:
- ""
-
sendTimeout
java.lang.String sendTimeoutSpecify the maximum amount of time in milliseconds to wait when sending a replyMessageto theoutputChannel. Defaults to-1- blocking indefinitely. It is applied only if the output channel has some 'sending' limitations, e.g.QueueChannelwith fixed a 'capacity'. In this case aMessageDeliveryExceptionis thrown. The 'sendTimeout' is ignored in case ofAbstractSubscribableChannelimplementations. Can be specified as 'property placeholder', e.g.${spring.integration.sendTimeout}.- Returns:
- The timeout for sending results to the reply target (in milliseconds)
- Default:
- ""
-
autoStartup
java.lang.String autoStartupTheSmartLifecycleautoStartupoption. Can be specified as 'property placeholder', e.g.${foo.autoStartup}. Defaults totrue.- Returns:
- the auto startup
booleanflag.
- Default:
- ""
-
phase
java.lang.String phaseSpecify aSmartLifecyclephaseoption. DefaultsInteger.MAX_VALUE / 2forPollingConsumerandInteger.MIN_VALUEforEventDrivenConsumer. Can be specified as 'property placeholder', e.g.${foo.phase}.- Returns:
- the
SmartLifecyclephase.
- Default:
- ""
-
poller
Poller[] poller- Returns:
- the
Polleroptions for a polled endpoint (PollerMetadata). This attribute is anarrayjust to allow an empty default (no poller). Only onePollerelement is allowed.
- Default:
- {}
-