Class AmqpInboundGateway
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.amqp.inbound.AmqpInboundGateway
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Lifecycle
,Phased
,SmartLifecycle
,ComponentSourceAware
,ExpressionCapable
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
Adapter that receives Messages from an AMQP Queue, converts them into
Spring Integration Messages, and sends the results to a Message Channel.
If a reply Message is received, it will be converted and sent back to
the AMQP 'replyTo'.
- Since:
- 2.1
- Author:
- Mark Fisher, Artem Bilan, Gary Russell, Ngoc Nhan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
MessagingGatewaySupport.ConvertingMessagingTemplate
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplate
Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLock
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.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionAmqpInboundGateway
(AbstractMessageListenerContainer listenerContainer) AmqpInboundGateway
(MessageListenerContainer listenerContainer, AmqpTemplate amqpTemplate) ConstructAmqpInboundGateway
based on the providedMessageListenerContainer
to receive request messages andAmqpTemplate
to send replies. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doStart()
Subclasses must implement this method with the start behavior.protected void
doStop()
Subclasses must implement this method with the stop behavior.Subclasses may implement this method to provide component type information.protected AttributeAccessor
getErrorMessageAttributes
(Message<?> message) Populate anAttributeAccessor
to be used when building an error message with theerrorMessageStrategy
.protected void
onInit()
Subclasses may implement this for initialization logic.void
setBatchingStrategy
(BatchingStrategy batchingStrategy) Set a batching strategy to use when de-batching messages.void
setBindSourceMessage
(boolean bindSourceMessage) Set to true to bind the source message in the header namedIntegrationMessageHeaderAccessor.SOURCE_DATA
.void
setDefaultReplyTo
(String defaultReplyTo) ThedefaultReplyTo
address with the formvoid
setHeaderMapper
(AmqpHeaderMapper headerMapper) void
setMessageConverter
(MessageConverter messageConverter) Specify theMessageConverter
to convert request and reply to/fromMessage
.void
setMessageRecoverer
(MessageRecoverer messageRecoverer) Configure aMessageRecoverer
for retry operations.void
setRecoveryCallback
(org.springframework.retry.RecoveryCallback<?> recoveryCallback) Set aRecoveryCallback
when using retry within the gateway.void
setReplyHeadersMappedLast
(boolean replyHeadersMappedLast) When mapping headers for the outbound (reply) message, determine whether the headers are mapped before the message is converted, or afterwards.void
setRetryTemplate
(org.springframework.retry.support.RetryTemplate retryTemplate) Set aRetryTemplate
to use for retrying a message delivery within the gateway.Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, buildSendTimer, destroy, getErrorChannel, getErrorMessageStrategy, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, isObserved, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerObservationRegistry, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setObservationConvention, setReceiverObservationConvention, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrack
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
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 org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
AmqpInboundGateway
-
AmqpInboundGateway
ConstructAmqpInboundGateway
based on the providedMessageListenerContainer
to receive request messages andAmqpTemplate
to send replies.- Parameters:
listenerContainer
- theMessageListenerContainer
to receive AMQP messages.amqpTemplate
- theAmqpTemplate
to send reply messages.
-
-
Method Details
-
setMessageConverter
Specify theMessageConverter
to convert request and reply to/fromMessage
. If theamqpTemplate
is explicitly set, thisMessageConverter
isn't populated there. You must configure that externalamqpTemplate
.- Parameters:
messageConverter
- theMessageConverter
to use.
-
setHeaderMapper
-
setDefaultReplyTo
ThedefaultReplyTo
address with the form(exchange)/(routingKey)
or(queueName)
if the request message doesn't have areplyTo
property. The second form uses the default exchange ("") and the queue name as the routing key.- Parameters:
defaultReplyTo
- the defaultreplyTo
address to use.- Since:
- 4.2
- See Also:
-
setRetryTemplate
public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate) Set aRetryTemplate
to use for retrying a message delivery within the gateway. Unlike adding retry at the container level, this can be used with anErrorMessageSendingRecoverer
RecoveryCallback
to publish to the error channel after retries are exhausted. You generally should not configure an error channel when using retry here, use aRecoveryCallback
instead.- Parameters:
retryTemplate
- the template.- Since:
- 4.3.10.
- See Also:
-
setRecoveryCallback
public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback) Set aRecoveryCallback
when using retry within the gateway. Mutually exclusive withsetMessageRecoverer(MessageRecoverer)
.- Parameters:
recoveryCallback
- the callback.- Since:
- 4.3.10
- See Also:
-
setMessageRecoverer
Configure aMessageRecoverer
for retry operations. A more AMQP-specific convenience instead ofsetRecoveryCallback(RecoveryCallback)
.- Parameters:
messageRecoverer
- theMessageRecoverer
to use.- Since:
- 5.5
-
setBatchingStrategy
Set a batching strategy to use when de-batching messages. Default isSimpleBatchingStrategy
.- Parameters:
batchingStrategy
- the strategy.- Since:
- 5.2
-
setBindSourceMessage
public void setBindSourceMessage(boolean bindSourceMessage) Set to true to bind the source message in the header namedIntegrationMessageHeaderAccessor.SOURCE_DATA
.- Parameters:
bindSourceMessage
- true to bind.- Since:
- 5.1.6
-
setReplyHeadersMappedLast
public void setReplyHeadersMappedLast(boolean replyHeadersMappedLast) When mapping headers for the outbound (reply) message, determine whether the headers are mapped before the message is converted, or afterwards. This only affects headers that might be added by the message converter. When false, the converter's headers win; when true, any headers added by the converter will be overridden (if the source message has a header that maps to those headers). You might wish to set this to true, for example, when using aSimpleMessageConverter
with a String payload that contains json; the converter will set the content type totext/plain
which can be overridden toapplication/json
by setting theAmqpHeaders.CONTENT_TYPE
message header. Default: false.- Parameters:
replyHeadersMappedLast
- true if reply headers are mapped after conversion.- Since:
- 5.1.9
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessagingGatewaySupport
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classMessagingGatewaySupport
-
doStart
protected void doStart()Description copied from class:AbstractEndpoint
Subclasses must implement this method with the start behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock
.- Overrides:
doStart
in classMessagingGatewaySupport
-
doStop
protected void doStop()Description copied from class:AbstractEndpoint
Subclasses must implement this method with the stop behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock
.- Overrides:
doStop
in classMessagingGatewaySupport
-
getErrorMessageAttributes
Description copied from class:MessagingGatewaySupport
Populate anAttributeAccessor
to be used when building an error message with theerrorMessageStrategy
.- Overrides:
getErrorMessageAttributes
in classMessagingGatewaySupport
- Parameters:
message
- the message.- Returns:
- the attributes.
-