public class HttpRequestExecutingMessageHandler extends AbstractHttpRequestExecutingMessageHandler
MessageHandler
implementation that executes HTTP requests by delegating
to a RestTemplate instance. If the 'expectReply' flag is set to true (the default)
then a reply Message will be generated from the HTTP response. If that response contains
a body, it will be used as the reply Message's payload. Otherwise the reply Message's
payload will contain the response status as an instance of the
HttpStatus enum.
When there is a response body, the HttpStatus enum
instance will instead be
copied to the MessageHeaders of the reply. In both cases, the response headers will
be mapped to the reply Message's headers by this handler's
HeaderMapper instance.AbstractReplyProducingMessageHandler.RequestHandlerIntegrationManagement.ManagementOverridesmessagingTemplateEXPRESSION_PARSER, loggerMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE| Constructor and Description |
|---|
HttpRequestExecutingMessageHandler(Expression uriExpression)
Create a handler that will send requests to the provided URI Expression.
|
HttpRequestExecutingMessageHandler(Expression uriExpression,
RestTemplate restTemplate)
Create a handler that will send requests to the provided URI using a provided RestTemplate
|
HttpRequestExecutingMessageHandler(String uri)
Create a handler that will send requests to the provided URI.
|
HttpRequestExecutingMessageHandler(String uri,
RestTemplate restTemplate)
Create a handler that will send requests to the provided URI using a provided RestTemplate
|
HttpRequestExecutingMessageHandler(URI uri)
Create a handler that will send requests to the provided URI.
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
exchange(java.util.function.Supplier<URI> uriSupplier,
HttpMethod httpMethod,
HttpEntity<?> httpRequest,
Object expectedResponseType,
Message<?> requestMessage) |
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
void |
setErrorHandler(ResponseErrorHandler errorHandler)
Set the
ResponseErrorHandler for the underlying RestTemplate. |
void |
setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
Set a list of
HttpMessageConverters to be used by the underlying RestTemplate. |
void |
setRequestFactory(ClientHttpRequestFactory requestFactory)
Set the
ClientHttpRequestFactory for the underlying RestTemplate. |
doInit, evaluateTypeFromExpression, getReply, handleRequestMessage, isExpectReply, mapHeaders, setCharset, setEncodeUri, setExpectedResponseType, setExpectedResponseTypeExpression, setExpectReply, setExtractPayload, setHeaderMapper, setHttpMethod, setHttpMethodExpression, setTransferCookies, setTrustedSpel, setUriVariableExpressions, setUriVariablesExpressiondoInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReplyaddNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadersconfigureMetrics, destroy, getActiveCount, getActiveCountLong, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMetricsCaptor, getMinDuration, getOrder, getOverrides, getStandardDeviationDuration, handleMessage, isCountsEnabled, isLoggingEnabled, isStatsEnabled, onComplete, onError, onNext, onSubscribe, registerMetricsCaptor, reset, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabledafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waiterrorCount, handleCountgetBeanName, getComponentNamepublic HttpRequestExecutingMessageHandler(URI uri)
uri - The URI.public HttpRequestExecutingMessageHandler(String uri)
uri - The URI.public HttpRequestExecutingMessageHandler(Expression uriExpression)
uriExpression - The URI expression.public HttpRequestExecutingMessageHandler(String uri, RestTemplate restTemplate)
uri - The URI.restTemplate - The rest template.public HttpRequestExecutingMessageHandler(Expression uriExpression, RestTemplate restTemplate)
uriExpression - A SpEL Expression that can be resolved against the message object and
BeanFactory.restTemplate - The rest template.public String getComponentType()
IntegrationObjectSupportgetComponentType in interface NamedComponentgetComponentType in class AbstractMessageHandlerpublic void setErrorHandler(ResponseErrorHandler errorHandler)
ResponseErrorHandler for the underlying RestTemplate.errorHandler - The error handler.RestTemplate.setErrorHandler(ResponseErrorHandler)public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
HttpMessageConverters to be used by the underlying RestTemplate.
Converters configured via this method will override the default converters.messageConverters - The message converters.RestTemplate.setMessageConverters(java.util.List)public void setRequestFactory(ClientHttpRequestFactory requestFactory)
ClientHttpRequestFactory for the underlying RestTemplate.requestFactory - The request factory.InterceptingHttpAccessor.setRequestFactory(ClientHttpRequestFactory)protected Object exchange(java.util.function.Supplier<URI> uriSupplier, HttpMethod httpMethod, HttpEntity<?> httpRequest, Object expectedResponseType, Message<?> requestMessage)
exchange in class AbstractHttpRequestExecutingMessageHandler