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 AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class AbstractHttpRequestExecutingMessageHandler
uriFactoryFields inherited from class AbstractMessageProducingHandler
messagingTemplateFields inherited from class IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionCreate a handler that will send requests to the provided URI.WebFluxRequestExecutingMessageHandler(String uri, @Nullable 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, @Nullable WebClient webClient) Create a handler that will send requests to the provided URI using a provided WebClient. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voiddoInit()protected @Nullable Objectexchange(Object uri, HttpMethod httpMethod, HttpEntity<?> httpRequest, Object expectedResponseType, Message<?> requestMessage, Map<String, ?> uriVariables) voidsetAttributeVariablesExpression(Expression attributeVariablesExpression) Configure expression to evaluate request attribute which will be added to webclient request attribute.voidsetBodyExtractor(BodyExtractor<?, ? super ClientHttpResponse> bodyExtractor) Specify aBodyExtractoras an alternative to theexpectedResponseTypeto allow to get low-level access to the receivedClientHttpResponse.voidsetEncodingMode(DefaultUriBuilderFactory.EncodingMode encodingMode) Set the encoding mode to use.voidsetPublisherElementType(Class<?> publisherElementType) Configure a type for a requestPublisherelements.voidsetPublisherElementTypeExpression(Expression publisherElementTypeExpression) Configure a SpEL expression to evaluate a requestPublisherelements type at runtime against a request message.voidsetReplyPayloadToFlux(boolean replyPayloadToFlux) The boolean flag to identify if the reply payload should be as aFluxfrom the response body or as resolved value from theMonoof the response body.Methods inherited from class AbstractHttpRequestExecutingMessageHandler
evaluateTypeFromExpression, getIntegrationPatternType, getReply, handleRequestMessage, isExpectReply, mapHeaders, setCharset, setExpectedResponseType, setExpectedResponseTypeExpression, setExpectReply, setExtractPayload, setExtractResponseBody, setHeaderMapper, setHttpMethod, setHttpMethodExpression, setTransferCookies, setTrustedSpel, setUriVariableExpressions, setUriVariablesExpressionMethods inherited from class AbstractReplyProducingMessageHandler
doInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReplyMethods inherited from class AbstractMessageProducingHandler
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class 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, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscriber
currentContextMethods inherited from interface IntegrationManagement
getThisAsMethods inherited from interface 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
-
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:AbstractHttpRequestExecutingMessageHandlerSet the encoding mode to use. By default, this is set toDefaultUriBuilderFactory.EncodingMode.TEMPLATE_AND_VALUES. For more complicated scenarios consider configuring anUriTemplateHandleron an externally providedRestTemplate.- Overrides:
setEncodingModein 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 aFluxfrom the response body or as resolved value from theMonoof the response body. Defaults tofalse- simple value is pushed downstream. Makes sense whenexpectedResponseTypeis configured.- Parameters:
replyPayloadToFlux- represent reply payload as aFluxor as a value from theMono.- Since:
- 5.0.1
- See Also:
-
setBodyExtractor
Specify aBodyExtractoras an alternative to theexpectedResponseTypeto allow to get low-level access to the receivedClientHttpResponse.- Parameters:
bodyExtractor- theBodyExtractorto use.- Since:
- 5.0.1
- See Also:
-
setPublisherElementType
Configure a type for a requestPublisherelements.- Parameters:
publisherElementType- the type of the requestPublisherelements.- Since:
- 5.2
- See Also:
-
setPublisherElementTypeExpression
Configure a SpEL expression to evaluate a requestPublisherelements type at runtime against a request message.- Parameters:
publisherElementTypeExpression- the expression to evaluate a type for the requestPublisherelements.- 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
- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageHandlerSupport
-
doInit
protected final void doInit()- Overrides:
doInitin classAbstractHttpRequestExecutingMessageHandler
-
exchange
protected @Nullable Object exchange(Object uri, HttpMethod httpMethod, HttpEntity<?> httpRequest, Object expectedResponseType, Message<?> requestMessage, Map<String, ?> uriVariables) - Specified by:
exchangein classAbstractHttpRequestExecutingMessageHandler
-