Annotation Interface Router


Indicates that a method is capable of resolving to a channel or channel name based on a message, message header(s), or both.

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.

Author:
Mark Fisher, Artem Bilan, Chris Bono
  • Element Details

    • inputChannel

      String inputChannel
      Specify the channel from which this router will consume messages. If the channel does not exist, a DirectChannel with this name will be registered in the application context.
      Returns:
      The channel name.
      Default:
      ""
    • defaultOutputChannel

      String defaultOutputChannel
      Specify the channel to which this router will send messages for which destination channels are not resolved and resolutionRequired() is false.
      Returns:
      The channel name.
      Default:
      ""
    • channelMappings

      String[] channelMappings
      The 'key=value' pairs to represent channelMapping entries.
      Returns:
      the channelMappings.
      See Also:
      Default:
      {}
    • prefix

      String prefix
      Specify a prefix to be added to each channel name prior to resolution.
      Returns:
      the prefix.
      Default:
      ""
    • suffix

      String suffix
      Specify a suffix to be added to each channel name prior to resolution.
      Returns:
      the suffix.
      Default:
      ""
    • resolutionRequired

      String resolutionRequired
      Specify whether channel names must always be successfully resolved to existing channel instances.

      If set to true (default), a MessagingException will be raised in case the channel cannot be resolved. Setting this attribute to false, 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

      String applySequence
      Specify whether sequence number and size headers should be added to each Message. Defaults to false. Can be specified as 'property placeholder', e.g. ${spring.integration.applySequence}.
      Returns:
      the apply sequence flag.
      Default:
      ""
    • ignoreSendFailures

      String ignoreSendFailures
      If set to true , failures to send to a message channel will be ignored. If set to false (default), a MessageDeliveryException will 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

      String sendTimeout
      Specify the maximum amount of time in milliseconds to wait when sending a reply Message to the outputChannel. Defaults to 30 seconds. It is applied only if the output channel has some 'sending' limitations, e.g. QueueChannel with fixed a 'capacity'. In this case a MessageDeliveryException is thrown. The 'sendTimeout' is ignored in case of AbstractSubscribableChannel implementations. 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

      String autoStartup
      The SmartLifecycle autoStartup option. Can be specified as 'property placeholder', e.g. ${foo.autoStartup}. Defaults to true.
      Returns:
      the auto startup boolean flag.
      Default:
      ""
    • phase

      String phase
      Specify a SmartLifecycle phase option. Defaults Integer.MAX_VALUE / 2 for PollingConsumer and Integer.MIN_VALUE for EventDrivenConsumer. Can be specified as 'property placeholder', e.g. ${foo.phase}.
      Returns:
      the SmartLifecycle phase.
      Default:
      ""
    • poller

      Poller poller
      Returns:
      the Poller options for a polled endpoint (PollerMetadata). Mutually exclusive with reactive().
      Default:
      @org.springframework.integration.annotation.Poller("\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n")
    • reactive

      Reactive reactive
      Returns:
      the Reactive marker for a consumer endpoint. Mutually exclusive with poller().
      Since:
      5.5
      Default:
      @org.springframework.integration.annotation.Reactive("\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n")