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
,ComponentSourceAware
,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, David Graff, Jatin Saxena, Ngoc Nhan
- See Also:
-
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
ConstructorDescriptionCreate 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.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 TypeMethodDescriptionprotected final void
doInit()
protected Object
exchange
(Object uri, HttpMethod httpMethod, HttpEntity<?> httpRequest, Object expectedResponseType, Message<?> requestMessage, Map<String, ?> uriVariables) Subclasses may implement this method to provide component type information.void
setAttributeVariablesExpression
(Expression attributeVariablesExpression) Configure expression to evaluate request attribute which will be added to webclient request attribute.void
setBodyExtractor
(BodyExtractor<?, ? super 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
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, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConvention
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, 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, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, 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 reactor.core.CoreSubscriber
currentContext
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 configuring 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:
-
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:
-
setPublisherElementType
Configure a type for a requestPublisher
elements.- Parameters:
publisherElementType
- the type of the requestPublisher
elements.- Since:
- 5.2
- See Also:
-
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:
-
setAttributeVariablesExpression
Configure expression to evaluate request attribute which will be added to webclient request attribute.- Parameters:
attributeVariablesExpression
- the expression to evaluate request attribute.- Since:
- 6.0
- See Also:
-
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
-
doInit
protected final void doInit()- Overrides:
doInit
in classAbstractHttpRequestExecutingMessageHandler
-
exchange
@Nullable protected Object exchange(Object uri, HttpMethod httpMethod, HttpEntity<?> httpRequest, Object expectedResponseType, Message<?> requestMessage, Map<String, ?> uriVariables) - Specified by:
exchange
in classAbstractHttpRequestExecutingMessageHandler
-