Class WebFluxRequestExecutingMessageHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.http.outbound.AbstractHttpRequestExecutingMessageHandler
org.springframework.integration.webflux.outbound.WebFluxRequestExecutingMessageHandler
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Ordered
,ExpressionCapable
,Orderable
,MessageProducer
,HeaderPropagationAware
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageHandler
,reactor.core.CoreSubscriber<Message<?>>
public class WebFluxRequestExecutingMessageHandler extends AbstractHttpRequestExecutingMessageHandler
A
MessageHandler
implementation that executes
HTTP requests by delegating to a Reactive WebClient
instance.- Since:
- 5.0
- Author:
- Shiliang Li, Artem Bilan, Gary Russell
- See Also:
HttpRequestExecutingMessageHandler
,WebClient
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandler
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.http.outbound.AbstractHttpRequestExecutingMessageHandler
uriFactory
Fields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
messagingTemplate
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors Constructor Description WebFluxRequestExecutingMessageHandler(String uri)
Create a handler that will send requests to the provided URI.WebFluxRequestExecutingMessageHandler(String uri, WebClient webClient)
Create a handler that will send requests to the provided URI using a provided WebClient.WebFluxRequestExecutingMessageHandler(URI uri)
Create a handler that will send requests to the provided URI.WebFluxRequestExecutingMessageHandler(Expression uriExpression)
Create a handler that will send requests to the provided URI Expression.WebFluxRequestExecutingMessageHandler(Expression uriExpression, WebClient webClient)
Create a handler that will send requests to the provided URI using a provided WebClient. -
Method Summary
Modifier and Type Method Description protected Object
exchange(Object uri, HttpMethod httpMethod, HttpEntity<?> httpRequest, Object expectedResponseType, Message<?> requestMessage, Map<String,?> uriVariables)
String
getComponentType()
Subclasses may implement this method to provide component type information.void
setBodyExtractor(BodyExtractor<?,ClientHttpResponse> bodyExtractor)
Specify aBodyExtractor
as an alternative to theexpectedResponseType
to allow to get low-level access to the receivedClientHttpResponse
.void
setEncodingMode(DefaultUriBuilderFactory.EncodingMode encodingMode)
Set the encoding mode to use.void
setPublisherElementType(Class<?> publisherElementType)
Configure a type for a requestPublisher
elements.void
setPublisherElementTypeExpression(Expression publisherElementTypeExpression)
Configure a SpEL expression to evaluate a requestPublisher
elements type at runtime against a request message.void
setReplyPayloadToFlux(boolean replyPayloadToFlux)
The boolean flag to identify if the reply payload should be as aFlux
from the response body or as resolved value from theMono
of the response body.Methods inherited from class org.springframework.integration.http.outbound.AbstractHttpRequestExecutingMessageHandler
doInit, evaluateTypeFromExpression, getIntegrationPatternType, getReply, handleRequestMessage, isExpectReply, mapHeaders, setCharset, setExpectedResponseType, setExpectedResponseTypeExpression, setExpectReply, setExtractPayload, setExtractResponseBody, setHeaderMapper, setHttpMethod, setHttpMethodExpression, setTransferCookies, setTrustedSpel, setUriVariableExpressions, setUriVariablesExpression
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
doInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply
Methods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
WebFluxRequestExecutingMessageHandler
Create a handler that will send requests to the provided URI.- Parameters:
uri
- The URI.
-
WebFluxRequestExecutingMessageHandler
Create a handler that will send requests to the provided URI.- Parameters:
uri
- The URI.
-
WebFluxRequestExecutingMessageHandler
Create a handler that will send requests to the provided URI Expression.- Parameters:
uriExpression
- The URI expression.
-
WebFluxRequestExecutingMessageHandler
Create a handler that will send requests to the provided URI using a provided WebClient.- Parameters:
uri
- The URI.webClient
- The WebClient to use.
-
WebFluxRequestExecutingMessageHandler
public WebFluxRequestExecutingMessageHandler(Expression uriExpression, @Nullable WebClient webClient)Create a handler that will send requests to the provided URI using a provided WebClient.- Parameters:
uriExpression
- A SpEL Expression that can be resolved against the message object andBeanFactory
.webClient
- The WebClient to use.
-
-
Method Details
-
setEncodingMode
Description copied from class:AbstractHttpRequestExecutingMessageHandler
Set the encoding mode to use. By default this is set toDefaultUriBuilderFactory.EncodingMode.TEMPLATE_AND_VALUES
. For more complicated scenarios consider to configure anUriTemplateHandler
on an externally providedRestTemplate
.- Overrides:
setEncodingMode
in classAbstractHttpRequestExecutingMessageHandler
- Parameters:
encodingMode
- the mode to use for uri encoding
-
setReplyPayloadToFlux
public void setReplyPayloadToFlux(boolean replyPayloadToFlux)The boolean flag to identify if the reply payload should be as aFlux
from the response body or as resolved value from theMono
of the response body. Defaults tofalse
- simple value is pushed downstream. Makes sense whenexpectedResponseType
is configured.- Parameters:
replyPayloadToFlux
- represent reply payload as aFlux
or as a value from theMono
.- Since:
- 5.0.1
- See Also:
AbstractHttpRequestExecutingMessageHandler.setExpectedResponseType(Class)
,AbstractHttpRequestExecutingMessageHandler.setExpectedResponseTypeExpression(Expression)
-
setBodyExtractor
Specify aBodyExtractor
as an alternative to theexpectedResponseType
to allow to get low-level access to the receivedClientHttpResponse
.- Parameters:
bodyExtractor
- theBodyExtractor
to use.- Since:
- 5.0.1
- See Also:
AbstractHttpRequestExecutingMessageHandler.setExpectedResponseType(Class)
,AbstractHttpRequestExecutingMessageHandler.setExpectedResponseTypeExpression(Expression)
-
setPublisherElementType
Configure a type for a requestPublisher
elements.- Parameters:
publisherElementType
- the type of the requestPublisher
elements.- Since:
- 5.2
- See Also:
BodyInserters.fromPublisher(Publisher, Class)
-
setPublisherElementTypeExpression
Configure a SpEL expression to evaluate a requestPublisher
elements type at runtime against a request message.- Parameters:
publisherElementTypeExpression
- the expression to evaluate a type for the requestPublisher
elements.- Since:
- 5.2
- See Also:
BodyInserters.fromPublisher(Publisher, Class)
,BodyInserters.fromPublisher(Publisher, ParameterizedTypeReference)
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessageHandlerSupport
-
exchange
@Nullable protected Object exchange(Object uri, HttpMethod httpMethod, HttpEntity<?> httpRequest, Object expectedResponseType, Message<?> requestMessage, Map<String,?> uriVariables)- Specified by:
exchange
in classAbstractHttpRequestExecutingMessageHandler
-