@IntegrationManagedResource public abstract class MessagingGatewaySupport extends AbstractEndpoint implements TrackableComponent, IntegrationInboundManagement, IntegrationPattern
MessageChannels for sending, receiving, or request-reply operations.
Exposes setters for configuring request and reply MessageChannels as
well as the timeout values for sending and receiving Messages.IntegrationManagement.ManagementOverrides| Modifier and Type | Field and Description |
|---|---|
protected MessagingTemplate |
messagingTemplate |
lifecycleCondition, lifecycleLockEXPRESSION_PARSER, loggerMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEDEFAULT_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, stopafterPropertiesSet, 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, waitgetThisAsgetBeanName, getComponentNameprotected 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 TrackableComponentpublic String getComponentType()
IntegrationObjectSupportgetComponentType in interface NamedComponentgetComponentType in class IntegrationObjectSupportpublic void setLoggingEnabled(boolean enabled)
IntegrationManagementsetLoggingEnabled in interface IntegrationManagementenabled - dalse to disable.public boolean isLoggingEnabled()
IntegrationManagementisLoggingEnabled in interface IntegrationManagementpublic 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()
IntegrationManagementgetOverrides in interface IntegrationManagementpublic void setManagedType(String managedType)
setManagedType in interface IntegrationManagementpublic String getManagedType()
getManagedType in interface IntegrationManagementpublic void setManagedName(String managedName)
setManagedName in interface IntegrationManagementpublic String getManagedName()
getManagedName in interface IntegrationManagementpublic IntegrationPatternType getIntegrationPatternType()
IntegrationPatterngetIntegrationPatternType in interface IntegrationPatternIntegrationPatternType this component implements.public void registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister)
IntegrationManagementMetricsCaptorregisterMetricsCaptor in interface IntegrationManagementmetricsCaptorToRegister - the captor.protected void onInit()
IntegrationObjectSupportonInit 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()
AbstractEndpointAbstractEndpoint.lifecycleLock.doStart in class AbstractEndpointprotected void doStop()
AbstractEndpointAbstractEndpoint.lifecycleLock.doStop in class AbstractEndpointpublic void destroy()
destroy in interface DisposableBeandestroy in interface IntegrationManagementdestroy in class AbstractEndpoint