@IntegrationManagedResource public abstract class MessagingGatewaySupport extends AbstractEndpoint implements TrackableComponent, MessageSourceMetrics
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
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 org.springframework.messaging.support.ErrorMessage |
buildErrorMessage(org.springframework.messaging.Message<?> requestMessage,
java.lang.Throwable throwable)
Build an error message for the message and throwable using the configured
ErrorMessageStrategy . |
protected void |
doStart()
Subclasses must implement this method with the start behavior.
|
protected void |
doStop()
Subclasses must implement this method with the stop behavior.
|
java.lang.String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
org.springframework.messaging.MessageChannel |
getErrorChannel()
Return the error channel (if provided) to which error messages will
be routed.
|
protected org.springframework.core.AttributeAccessor |
getErrorMessageAttributes(org.springframework.messaging.Message<?> message)
Populate an
AttributeAccessor to be used when building an error message
with the errorMessageStrategy . |
java.lang.String |
getManagedName() |
java.lang.String |
getManagedType() |
int |
getMessageCount() |
long |
getMessageCountLong() |
IntegrationManagement.ManagementOverrides |
getOverrides()
Return the overrides.
|
org.springframework.messaging.MessageChannel |
getReplyChannel()
Return this gateway's reply channel if any.
|
org.springframework.messaging.MessageChannel |
getRequestChannel()
Return this gateway's request channel.
|
boolean |
isCountsEnabled() |
boolean |
isLoggingEnabled() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected java.lang.Object |
receive() |
protected java.lang.Object |
receive(long timeout) |
protected org.springframework.messaging.Message<?> |
receiveMessage() |
protected org.springframework.messaging.Message<?> |
receiveMessage(long timeout) |
protected void |
registerReplyMessageCorrelatorIfNecessary() |
void |
reset() |
protected void |
send(java.lang.Object object) |
protected java.lang.Object |
sendAndReceive(java.lang.Object object) |
protected org.springframework.messaging.Message<?> |
sendAndReceiveMessage(java.lang.Object object) |
protected reactor.core.publisher.Mono<org.springframework.messaging.Message<?>> |
sendAndReceiveMessageReactive(java.lang.Object object) |
void |
setCountsEnabled(boolean countsEnabled) |
void |
setErrorChannel(org.springframework.messaging.MessageChannel errorChannel)
Set the error channel.
|
void |
setErrorChannelName(java.lang.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 |
setLoggingEnabled(boolean enabled) |
void |
setManagedName(java.lang.String name) |
void |
setManagedType(java.lang.String type) |
void |
setReplyChannel(org.springframework.messaging.MessageChannel replyChannel)
Set the reply channel.
|
void |
setReplyChannelName(java.lang.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(org.springframework.messaging.MessageChannel requestChannel)
Set the request channel.
|
void |
setRequestChannelName(java.lang.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.
|
destroy, doStop, getPhase, getRole, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, setTaskScheduler, start, stop, stop
afterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getComponentName
setCounter
registerMetricsCaptor
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.public void setRequestChannel(org.springframework.messaging.MessageChannel requestChannel)
requestChannel
- the channel to which request messages will be sentpublic void setRequestChannelName(java.lang.String requestChannelName)
requestChannelName
- the channel bean name to which request messages will be sentpublic void setReplyChannel(org.springframework.messaging.MessageChannel replyChannel)
replyChannel
- the channel from which reply messages will be receivedpublic void setReplyChannelName(java.lang.String replyChannelName)
replyChannelName
- the channel bean name from which reply messages will be receivedpublic void setErrorChannel(org.springframework.messaging.MessageChannel errorChannel)
errorChannel
- The error channel.public void setErrorChannelName(java.lang.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(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 int getMessageCount()
getMessageCount
in interface MessageSourceMetrics
public long getMessageCountLong()
getMessageCountLong
in interface MessageSourceMetrics
public void setManagedName(java.lang.String name)
setManagedName
in interface MessageSourceMetrics
public java.lang.String getManagedName()
getManagedName
in interface MessageSourceMetrics
public void setManagedType(java.lang.String type)
setManagedType
in interface MessageSourceMetrics
public java.lang.String getManagedType()
getManagedType
in interface MessageSourceMetrics
public java.lang.String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class IntegrationObjectSupport
public void setLoggingEnabled(boolean enabled)
setLoggingEnabled
in interface IntegrationManagement
public boolean isLoggingEnabled()
isLoggingEnabled
in interface IntegrationManagement
public void setCountsEnabled(boolean countsEnabled)
setCountsEnabled
in interface IntegrationManagement
public boolean isCountsEnabled()
isCountsEnabled
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
protected void onInit() throws java.lang.Exception
IntegrationObjectSupport
onInit
in class AbstractEndpoint
java.lang.Exception
- Any exception.public org.springframework.messaging.MessageChannel getRequestChannel()
public org.springframework.messaging.MessageChannel getReplyChannel()
public org.springframework.messaging.MessageChannel getErrorChannel()
protected void send(java.lang.Object object)
protected java.lang.Object receive()
protected org.springframework.messaging.Message<?> receiveMessage()
protected java.lang.Object receive(long timeout)
protected org.springframework.messaging.Message<?> receiveMessage(long timeout)
protected java.lang.Object sendAndReceive(java.lang.Object object)
protected org.springframework.messaging.Message<?> sendAndReceiveMessage(java.lang.Object object)
protected reactor.core.publisher.Mono<org.springframework.messaging.Message<?>> sendAndReceiveMessageReactive(java.lang.Object object)
protected final org.springframework.messaging.support.ErrorMessage buildErrorMessage(org.springframework.messaging.Message<?> requestMessage, java.lang.Throwable throwable)
ErrorMessageStrategy
.requestMessage
- the requestMessage.throwable
- the throwable.protected org.springframework.core.AttributeAccessor getErrorMessageAttributes(org.springframework.messaging.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 reset()
reset
in interface IntegrationManagement