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 ClassesNested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
MessagingGatewaySupport.ConvertingMessagingTemplateNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionAmqpInboundGateway(AbstractMessageListenerContainer listenerContainer) AmqpInboundGateway(MessageListenerContainer listenerContainer, AmqpTemplate amqpTemplate) ConstructAmqpInboundGatewaybased on the providedMessageListenerContainerto receive request messages andAmqpTemplateto send replies. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()Subclasses must implement this method with the start behavior.protected voiddoStop()Subclasses must implement this method with the stop behavior.protected AttributeAccessorgetErrorMessageAttributes(@Nullable Message<?> message) Populate anAttributeAccessorto be used when building an error message with theerrorMessageStrategy.protected voidonInit()Subclasses may implement this for initialization logic.voidsetBatchingStrategy(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(String defaultReplyTo) ThedefaultReplyToaddress with the formvoidsetHeaderMapper(AmqpHeaderMapper headerMapper) voidsetMessageConverter(MessageConverter messageConverter) Specify theMessageConverterto convert request and reply to/fromMessage.voidsetMessageRecoverer(MessageRecoverer messageRecoverer) Configure aMessageRecovererfor retry operations.voidsetRecoveryCallback(RecoveryCallback<?> 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 afterward.voidsetRetryTemplate(org.springframework.core.retry.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, 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, 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, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentNameMethods inherited from interface org.springframework.context.SmartLifecycle
isPauseable
-
Constructor Details
-
AmqpInboundGateway
-
AmqpInboundGateway
ConstructAmqpInboundGatewaybased on the providedMessageListenerContainerto receive request messages andAmqpTemplateto send replies.- Parameters:
listenerContainer- theMessageListenerContainerto receive AMQP messages.amqpTemplate- theAmqpTemplateto send reply messages.
-
-
Method Details
-
setMessageConverter
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
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:
-
setRetryTemplate
public void setRetryTemplate(org.springframework.core.retry.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
Set aRecoveryCallbackwhen using retry within the gateway. Mutually exclusive withsetMessageRecoverer(MessageRecoverer).- Parameters:
recoveryCallback- the callback.- Since:
- 4.3.10
- See Also:
-
setMessageRecoverer
Configure aMessageRecovererfor retry operations. A more AMQP-specific convenience instead ofsetRecoveryCallback(RecoveryCallback).- Parameters:
messageRecoverer- theMessageRecovererto 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 afterward. 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
- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessagingGatewaySupport
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classMessagingGatewaySupport
-
doStart
protected void doStart()Description copied from class:AbstractEndpointSubclasses must implement this method with the start behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Overrides:
doStartin classMessagingGatewaySupport
-
doStop
protected void doStop()Description copied from class:AbstractEndpointSubclasses must implement this method with the stop behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Overrides:
doStopin classMessagingGatewaySupport
-
getErrorMessageAttributes
Description copied from class:MessagingGatewaySupportPopulate anAttributeAccessorto be used when building an error message with theerrorMessageStrategy.- Overrides:
getErrorMessageAttributesin classMessagingGatewaySupport- Parameters:
message- the message.- Returns:
- the attributes.
-