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:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,org.springframework.integration.context.ExpressionCapable,org.springframework.integration.IntegrationPattern,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationInboundManagement,org.springframework.integration.support.management.IntegrationManagement,org.springframework.integration.support.management.ManageableLifecycle,org.springframework.integration.support.management.ManageableSmartLifecycle,org.springframework.integration.support.management.TrackableComponent
public class AmqpInboundGateway
extends org.springframework.integration.gateway.MessagingGatewaySupport
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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAmqpInboundGateway.Listener -
Field Summary
Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger -
Constructor Summary
Constructors Constructor Description AmqpInboundGateway(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer listenerContainer)AmqpInboundGateway(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer listenerContainer, org.springframework.amqp.core.AmqpTemplate amqpTemplate)ConstructAmqpInboundGatewaybased on the providedAbstractMessageListenerContainerto receive request messages andAmqpTemplateto send replies. -
Method Summary
Modifier and Type Method Description protected voiddoStart()protected voiddoStop()java.lang.StringgetComponentType()protected org.springframework.core.AttributeAccessorgetErrorMessageAttributes(org.springframework.messaging.Message<?> message)protected voidonInit()voidsetBatchingStrategy(org.springframework.amqp.rabbit.batch.BatchingStrategy batchingStrategy)Set a batching strategy to use when de-batching messages.voidsetBindSourceMessage(boolean bindSourceMessage)Set to true to bind the source message in the header namedIntegrationMessageHeaderAccessor.SOURCE_DATA.voidsetDefaultReplyTo(java.lang.String defaultReplyTo)ThedefaultReplyToaddress with the formvoidsetHeaderMapper(AmqpHeaderMapper headerMapper)voidsetMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter)Specify theMessageConverterto convert request and reply to/fromMessage.voidsetMessageRecoverer(org.springframework.amqp.rabbit.retry.MessageRecoverer messageRecoverer)Configure aMessageRecovererfor retry operations.voidsetRecoveryCallback(org.springframework.retry.RecoveryCallback<? extends java.lang.Object> recoveryCallback)Set aRecoveryCallbackwhen using retry within the gateway.voidsetReplyHeadersMappedLast(boolean replyHeadersMappedLast)When mapping headers for the outbound (reply) message, determine whether the headers are mapped before the message is converted, or afterwards.voidsetRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)Set aRetryTemplateto use for retrying a message delivery within the gateway.Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, buildSendTimer, destroy, getErrorChannel, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrackMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
AmqpInboundGateway
public AmqpInboundGateway(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer listenerContainer) -
AmqpInboundGateway
public AmqpInboundGateway(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer listenerContainer, org.springframework.amqp.core.AmqpTemplate amqpTemplate)ConstructAmqpInboundGatewaybased on the providedAbstractMessageListenerContainerto receive request messages andAmqpTemplateto send replies.- Parameters:
listenerContainer- theAbstractMessageListenerContainerto receive AMQP messages.amqpTemplate- theAmqpTemplateto send reply messages.- Since:
- 4.2
-
-
Method Details
-
setMessageConverter
public void setMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter)Specify theMessageConverterto convert request and reply to/fromMessage. If theamqpTemplateis explicitly set, thisMessageConverterisn't populated there. You must configure that externalamqpTemplate.- Parameters:
messageConverter- theMessageConverterto use.
-
setHeaderMapper
-
setDefaultReplyTo
public void setDefaultReplyTo(java.lang.String defaultReplyTo)ThedefaultReplyToaddress with the form(exchange)/(routingKey)
or(queueName)
if the request message doesn't have areplyToproperty. The second form uses the default exchange ("") and the queue name as the routing key.- Parameters:
defaultReplyTo- the defaultreplyToaddress to use.- Since:
- 4.2
- See Also:
Address
-
setRetryTemplate
public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)Set aRetryTemplateto use for retrying a message delivery within the gateway. Unlike adding retry at the container level, this can be used with anErrorMessageSendingRecovererRecoveryCallbackto publish to the error channel after retries are exhausted. You generally should not configure an error channel when using retry here, use aRecoveryCallbackinstead.- Parameters:
retryTemplate- the template.- Since:
- 4.3.10.
- See Also:
setRecoveryCallback(RecoveryCallback)
-
setRecoveryCallback
public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<? extends java.lang.Object> recoveryCallback)Set aRecoveryCallbackwhen using retry within the gateway. Mutually exclusive withsetMessageRecoverer(MessageRecoverer).- Parameters:
recoveryCallback- the callback.- Since:
- 4.3.10
- See Also:
setRetryTemplate(RetryTemplate)
-
setMessageRecoverer
public void setMessageRecoverer(org.springframework.amqp.rabbit.retry.MessageRecoverer messageRecoverer)Configure aMessageRecovererfor retry operations. A more AMQP-specific convenience instead ofsetRecoveryCallback(RecoveryCallback).- Parameters:
messageRecoverer- theMessageRecovererto use.- Since:
- 5.5
-
setBatchingStrategy
public void setBatchingStrategy(org.springframework.amqp.rabbit.batch.BatchingStrategy batchingStrategy)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 aSimpleMessageConverterwith a String payload that contains json; the converter will set the content type totext/plainwhich can be overridden toapplication/jsonby setting theAmqpHeaders.CONTENT_TYPEmessage header. Default: false.- Parameters:
replyHeadersMappedLast- true if reply headers are mapped after conversion.- Since:
- 5.1.9
-
getComponentType
public java.lang.String getComponentType()- Specified by:
getComponentTypein interfaceorg.springframework.integration.support.context.NamedComponent- Overrides:
getComponentTypein classorg.springframework.integration.gateway.MessagingGatewaySupport
-
onInit
protected void onInit()- Overrides:
onInitin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStart
protected void doStart()- Overrides:
doStartin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStop
protected void doStop()- Overrides:
doStopin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
getErrorMessageAttributes
protected org.springframework.core.AttributeAccessor getErrorMessageAttributes(org.springframework.messaging.Message<?> message)- Overrides:
getErrorMessageAttributesin classorg.springframework.integration.gateway.MessagingGatewaySupport
-