HTTP inbound gateway
Gateway for receiving messages over HTTP and sending replies back.
The HTTP inbound adapters need to be deployed within a servlet container.
In sending a response to the client there are a number of ways to customize the behavior of the gateway.
By default the gateway will simply acknowledge that the request was received by sending a 200
status code back. Customize this response by providing a view name. If you simply want to acknowledge the received HTTP request without sending a response message back, use a HTTP inbound channel adapter instead.
Supported methods
Comma-separated HTTP method names. Determines which types of request are allowed with this endpoint. Possible methods are: GET, POST, HEAD, OPTIONS, PUT, DELETE and TRACE.
Default is POST, GET
.
Extract reply payload
Specify whether only the reply Message's payload should be passed in the response.
If this is set to 'false', the entire Message will be used to generate the response.
The default is 'true'.
Mapped request headers
Comma-separated list of names of HTTP headers to be mapped from the HTTP request into the message headers. The values in this list can also be simple patterns to be matched against the header names (e.g. foo
or foo
). The string HTTP_REQUEST_HEADERS
will match against any of the standard HTTP request headers.
All standard HTTP request headers are mapped by default.
Note that all non-standard headers will automatically be prefixed with X-
. This behaviour can be changed by using a custom header mapper.
Mapped response headers
Comma-separated list of names of m essage headers to be mapped into the HTTP headers of the HTTP response. The values in this list can also be simple patterns to be matched against the header names (e.g. foo
or foo
). The string HTTP_RESPONSE_HEADERS
will match against any of the standard HTTP response headers.
All standard HTTP response headers are mapped by default.
Note that all non-standard headers will automatically be prefixed with X-
. This behaviour can be changed by using a custom header mapper.
Header mapper
A custom HeaderMapper
implementation can be used to fully control the mapping between message headers and HTTP headers. For example, to configure whether to use the X-
prefix for user-defined HTTP headers or not.
This setting is mutually exclusive with mapped request headers and mapped response headers.
Convert exceptions
In the case that a view name is not specified, this attribute can be used to override the default behaviour when there is a message handling exception (which is to rethrow). If this flag is true
then the normal conversion process will be applied to the exception and written out to the response body.
Default is false
.
Payload expression
A SpEL expression that is evaluated in order to generate the message payload.
The evaluation context will be populated with an org.springframework.http.HttpEntity
instance as the root object, and the following expression variables will also be made available:
#requestParams - a MultiValueMap<String, String>
containing the request parameters from the query string or posted form data
#pathVariables - a Map<String, String>
containing the URI path placeholders and their values
#matrixVariables - a Map<String, MultiValueMap<String, String>>
containing the matrix variables according to Spring MVC specification
#requestAttributes - the org.springframework.web.context.request.RequestAttributes
associated with the current request
#requestHeaders - the org.springframework.http.HttpHeaders
object from the current request
#cookies - a Map<String, javax.servlet.http.Cookie>
containing the cookies from the current request
Optional
Path
Allows you to specify the URI path (e.g. /order/{orderId}
).
Any {variable}
in this path will be available in the SpEL evaluation context as an entry in the #pathVariables
map.
Ant-style path patterns are also supported (e.g. /myPath/*.do
).
Request payload type
Target type for payload that is the conversion result of the request.
By default this value is null
which means at runtime any "text" Content-Type will result in java.lang.String
while all others default to byte[]
.
Request timeout
Set the send timeout value for sending messages to the request channel.
Default is 1000
(1 second).
Reply timeout
Set the receive timeout value for receiving messages from the reply channel.
Default is 1000
(1 second).
Reply timeout status code expression
A SpEL expression that resolves to an HttpStatus
code when rendering a response after a reply timeout. The expression must return an object which can be converted to a org.springframework.http.HttpStatus
enum value. The evaluation context has a bean resolver but no variables, so the usage of this attribute is somewhat limited.
An example might be to resolve, at runtime, some scoped bean that returns an HttpStatus
value, or use a literal expression e.g. 504
.
By default reply timeout status code expression is null
, meaning that the default '500 Internal Server Error' response status will be returned after a timeout. When a timeout is not encountered, the HTTP inbound gateway resolves the status code from the http_statusCode
header of the reply message.
View name
View name to be resolved when rendering a response.
Reply key
Specify the key to be used when adding the reply Message or payload to the model map, depending on the value of Extract reply payload.
Default when empty: reply
Errors key
In the case that a view name is specified this attribute can be used to override the default key of the errors (if the request cannot be handled).
Defaults to errors
(similar to normal MVC usage).
Error code
In the case that a view name is specified this attribute can be used to override the default error code under which the handling exception is exposed.
Defaults to spring.integration.http.handler.error
and is supplied with 3 parameters: the exception itself, its message and its stack trace as a string.
Error channel
The channel that error messages will be sent to if a failure occurs in this gateway's invocation. To completely suppress exceptions, provide a reference to the nullChannel here.
Custom message headers that will be added to request messages send by this gateway.
The value is determined by a SpEL expression, which has access to the body and headers of the incoming HTTP request, any path variables (as defined by the path property) and any query parameters from the request URL.
Request channel
Channel where request messages should be sent to.
You can select the nullChannel
here to silently drop the request messages.
Required
Reply channel
Channel to consume the reply messages from.
Required
Id
Name that uniquely identifies this flow component.
Required