@IntegrationManagedResource public abstract class MessagingGatewaySupport extends AbstractEndpoint implements TrackableComponent, IntegrationInboundManagement, IntegrationPattern
MessageChannel
s for sending, receiving, or request-reply operations.
Exposes setters for configuring request and reply MessageChannel
s as
well as the timeout values for sending and receiving Messages.IntegrationManagement.ManagementOverrides
Modifier and Type | Field and Description |
---|---|
protected MessagingTemplate |
messagingTemplate |
lifecycleCondition, lifecycleLock
EXPRESSION_PARSER, logger
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
DEFAULT_PHASE
Constructor and Description |
---|
MessagingGatewaySupport()
Construct an instance that will return null if no reply is received.
|
MessagingGatewaySupport(boolean errorOnTimeout)
If errorOnTimeout is true, construct an instance that will send an
ErrorMessage with a MessageTimeoutException payload to the error
channel if a reply is expected but none is received. |
Modifier and Type | Method and Description |
---|---|
protected ErrorMessage |
buildErrorMessage(Message<?> requestMessage,
Throwable throwable)
Build an error message for the message and throwable using the configured
ErrorMessageStrategy . |
protected TimerFacade |
buildSendTimer(boolean success,
String exception) |
void |
destroy() |
protected void |
doStart()
Subclasses must implement this method with the start behavior.
|
protected void |
doStop()
Subclasses must implement this method with the stop behavior.
|
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
MessageChannel |
getErrorChannel()
Return the error channel (if provided) to which error messages will
be routed.
|
protected AttributeAccessor |
getErrorMessageAttributes(Message<?> message)
Populate an
AttributeAccessor to be used when building an error message
with the errorMessageStrategy . |
IntegrationPatternType |
getIntegrationPatternType()
Return a pattern type this component implements.
|
String |
getManagedName() |
String |
getManagedType() |
IntegrationManagement.ManagementOverrides |
getOverrides()
Return the overrides.
|
MessageChannel |
getReplyChannel()
Return this gateway's reply channel if any.
|
MessageChannel |
getRequestChannel()
Return this gateway's request channel.
|
boolean |
isLoggingEnabled()
Return whether logging is enabled.
|
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected Object |
receive() |
protected Object |
receive(long timeout) |
protected Message<?> |
receiveMessage() |
protected Message<?> |
receiveMessage(long timeout) |
void |
registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister)
Inject a
MetricsCaptor |
protected void |
registerReplyMessageCorrelatorIfNecessary() |
protected void |
send(Object object) |
protected Object |
sendAndReceive(Object object) |
protected Message<?> |
sendAndReceiveMessage(Object object) |
protected reactor.core.publisher.Mono<Message<?>> |
sendAndReceiveMessageReactive(Object object) |
protected TimerFacade |
sendTimer() |
void |
setErrorChannel(MessageChannel errorChannel)
Set the error channel.
|
void |
setErrorChannelName(String errorChannelName)
Set the error channel name.
|
void |
setErrorMessageStrategy(ErrorMessageStrategy errorMessageStrategy)
Set an
ErrorMessageStrategy to use to build an error message when a exception occurs. |
void |
setErrorOnTimeout(boolean errorOnTimeout)
If errorOnTimeout is true, construct an instance that will send an
ErrorMessage with a MessageTimeoutException payload to the error
channel if a reply is expected but none is received. |
void |
setLoggingEnabled(boolean enabled)
Enable logging or not.
|
void |
setManagedName(String managedName) |
void |
setManagedType(String managedType) |
void |
setReplyChannel(MessageChannel replyChannel)
Set the reply channel.
|
void |
setReplyChannelName(String replyChannelName)
Set the reply channel name.
|
void |
setReplyMapper(OutboundMessageMapper<?> replyMapper)
Provide an
OutboundMessageMapper for mapping to objects from
any reply Messages received in receive or sendAndReceive operations. |
void |
setReplyTimeout(long replyTimeout)
Set the timeout value for receiving reply messages.
|
void |
setRequestChannel(MessageChannel requestChannel)
Set the request channel.
|
void |
setRequestChannelName(String requestChannelName)
Set the request channel name.
|
void |
setRequestMapper(InboundMessageMapper<?> requestMapper)
Provide an
InboundMessageMapper for creating request Messages
from any object passed in a send or sendAndReceive operation. |
void |
setRequestTimeout(long requestTimeout)
Set the timeout value for sending request messages.
|
void |
setShouldTrack(boolean shouldTrack)
Specify whether this gateway should be tracked in the Message History
of Messages that originate from its send or sendAndReceive operations.
|
doStop, getPhase, getRole, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getThisAs
getBeanName, getComponentName
protected final MessagingTemplate messagingTemplate
public MessagingGatewaySupport()
public MessagingGatewaySupport(boolean errorOnTimeout)
ErrorMessage
with a MessageTimeoutException
payload to the error
channel if a reply is expected but none is received. If no error channel is
configured, the MessageTimeoutException
will be thrown.errorOnTimeout
- true to create the error message.setErrorOnTimeout(boolean)
public void setErrorOnTimeout(boolean errorOnTimeout)
ErrorMessage
with a MessageTimeoutException
payload to the error
channel if a reply is expected but none is received. If no error channel is
configured, the MessageTimeoutException
will be thrown.errorOnTimeout
- true to create the error message on reply timeout.public void setRequestChannel(MessageChannel requestChannel)
requestChannel
- the channel to which request messages will be sentpublic void setRequestChannelName(String requestChannelName)
requestChannelName
- the channel bean name to which request messages will be sentpublic void setReplyChannel(MessageChannel replyChannel)
replyChannel
- the channel from which reply messages will be receivedpublic void setReplyChannelName(String replyChannelName)
replyChannelName
- the channel bean name from which reply messages will be receivedpublic void setErrorChannel(MessageChannel errorChannel)
errorChannel
- The error channel.public void setErrorChannelName(String errorChannelName)
errorChannelName
- The error channel bean name.public void setRequestTimeout(long requestTimeout)
requestTimeout
- the timeout value in millisecondspublic void setReplyTimeout(long replyTimeout)
replyTimeout
- the timeout value in millisecondspublic void setRequestMapper(@Nullable InboundMessageMapper<?> requestMapper)
InboundMessageMapper
for creating request Messages
from any object passed in a send or sendAndReceive operation.requestMapper
- The request mapper.public void setReplyMapper(OutboundMessageMapper<?> replyMapper)
OutboundMessageMapper
for mapping to objects from
any reply Messages received in receive or sendAndReceive operations.replyMapper
- The reply mapper.public void setShouldTrack(boolean shouldTrack)
setShouldTrack
in interface TrackableComponent
public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class IntegrationObjectSupport
public void setLoggingEnabled(boolean enabled)
IntegrationManagement
setLoggingEnabled
in interface IntegrationManagement
enabled
- dalse to disable.public boolean isLoggingEnabled()
IntegrationManagement
isLoggingEnabled
in interface IntegrationManagement
public final void setErrorMessageStrategy(ErrorMessageStrategy errorMessageStrategy)
ErrorMessageStrategy
to use to build an error message when a exception occurs.
Default is the DefaultErrorMessageStrategy
.errorMessageStrategy
- the ErrorMessageStrategy
.public IntegrationManagement.ManagementOverrides getOverrides()
IntegrationManagement
getOverrides
in interface IntegrationManagement
public void setManagedType(String managedType)
setManagedType
in interface IntegrationManagement
public String getManagedType()
getManagedType
in interface IntegrationManagement
public void setManagedName(String managedName)
setManagedName
in interface IntegrationManagement
public String getManagedName()
getManagedName
in interface IntegrationManagement
public IntegrationPatternType getIntegrationPatternType()
IntegrationPattern
getIntegrationPatternType
in interface IntegrationPattern
IntegrationPatternType
this component implements.public void registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister)
IntegrationManagement
MetricsCaptor
registerMetricsCaptor
in interface IntegrationManagement
metricsCaptorToRegister
- the captor.protected void onInit()
IntegrationObjectSupport
onInit
in class AbstractEndpoint
@Nullable public MessageChannel getRequestChannel()
@Nullable public MessageChannel getReplyChannel()
@Nullable public MessageChannel getErrorChannel()
protected void send(Object object)
protected reactor.core.publisher.Mono<Message<?>> sendAndReceiveMessageReactive(Object object)
protected TimerFacade sendTimer()
protected TimerFacade buildSendTimer(boolean success, String exception)
protected final ErrorMessage buildErrorMessage(@Nullable Message<?> requestMessage, Throwable throwable)
ErrorMessageStrategy
.requestMessage
- the requestMessage.throwable
- the throwable.protected AttributeAccessor getErrorMessageAttributes(@Nullable Message<?> message)
AttributeAccessor
to be used when building an error message
with the errorMessageStrategy
.message
- the message.protected void registerReplyMessageCorrelatorIfNecessary()
protected void doStart()
AbstractEndpoint
AbstractEndpoint.lifecycleLock
.doStart
in class AbstractEndpoint
protected void doStop()
AbstractEndpoint
AbstractEndpoint.lifecycleLock
.doStop
in class AbstractEndpoint
public void destroy()
destroy
in interface DisposableBean
destroy
in interface IntegrationManagement
destroy
in class AbstractEndpoint