Annotation Interface Gateway


Indicates that an interface method is capable of mapping its parameters to a message or message payload. These method-level annotations are detected by the GatewayProxyFactoryBean where the annotation attributes can override the default channel settings.

A method annotated with @Gateway may accept a single non-annotated parameter of type Message or of the intended Message payload type. Method parameters may be mapped to individual Message header values by using the @Header parameter annotation. Alternatively, to pass the entire Message headers map, a Map-typed parameter may be annotated with Headers.

Return values from the annotated method may be of any type. If the declared return value is not a Message, the reply Message's payload will be returned and any type conversion as supported by Spring's SimpleTypeConverter will be applied to the return value if necessary.

Note: unlike @Publisher, this annotation is for exposing a Messaging Endpoint based on a Proxy for the marked interface method. The method invocation causes messaging interaction using an AOP Advice. Method parameters become the part of sent message (payload, headers). The method return value is the result (payload) of the messaging flow invoked by the Proxy.

Author:
Mark Fisher, Gary Russell, Artem Bilan
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Specify additional headers that will be added to the request message.
    Specify a SpEL expression to determine the payload of the request message.
    Specify the channel from which reply messages will be received; overrides the encompassing gateway's default reply channel.
    long
    Specify the time (ms) that the thread sending the request will wait for a reply.
    Specify a SpEL Expression to determine the time (ms) that the thread sending the request will wait for a reply.
    Specify the channel to which messages will be sent; overrides the encompassing gateway's default request channel.
    long
    Specify the timeout (ms) when sending to the request channel - only applies if the send might block (such as a bounded QueueChannel that is currently full.
    Specify a SpEL Expression to determine the timeout (ms) when sending to the request channel - only applies if the send might block (such as a bounded QueueChannel that is currently full.
  • Element Details

    • requestChannel

      String requestChannel
      Specify the channel to which messages will be sent; overrides the encompassing gateway's default request channel.
      Returns:
      the channel name.
      Default:
      ""
    • replyChannel

      String replyChannel
      Specify the channel from which reply messages will be received; overrides the encompassing gateway's default reply channel.
      Returns:
      the channel name.
      Default:
      ""
    • requestTimeout

      long requestTimeout
      Specify the timeout (ms) when sending to the request channel - only applies if the send might block (such as a bounded QueueChannel that is currently full. Overrides the encompassing gateway's default request timeout.
      Returns:
      the timeout.
      See Also:
      Default:
      30000L
    • requestTimeoutExpression

      String requestTimeoutExpression
      Specify a SpEL Expression to determine the timeout (ms) when sending to the request channel - only applies if the send might block (such as a bounded QueueChannel that is currently full. Overrides the encompassing gateway's default request timeout. Overrides requestTimeout().
      Returns:
      the timeout.
      Since:
      5.0
      Default:
      ""
    • replyTimeout

      long replyTimeout
      Specify the time (ms) that the thread sending the request will wait for a reply. The timer starts when the thread returns to the gateway, not when the request message is sent. Overrides the encompassing gateway's default reply timeout.
      Returns:
      the timeout.
      See Also:
      Default:
      30000L
    • replyTimeoutExpression

      String replyTimeoutExpression
      Specify a SpEL Expression to determine the time (ms) that the thread sending the request will wait for a reply. The timer starts when the thread returns to the gateway, not when the request message is sent. Overrides the encompassing gateway's default reply timeout. Overrides replyTimeout().
      Returns:
      the timeout.
      Since:
      5.0
      Default:
      ""
    • payloadExpression

      String payloadExpression
      Specify a SpEL expression to determine the payload of the request message.
      Returns:
      the expression.
      Default:
      ""
    • headers

      GatewayHeader[] headers
      Specify additional headers that will be added to the request message.
      Returns:
      the headers.
      Default:
      {}