Class AmqpInboundChannelAdapter
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter
- All Implemented Interfaces:
Aware,BeanFactoryAware,BeanNameAware,DisposableBean,InitializingBean,SmartInitializingSingleton,ApplicationContextAware,Lifecycle,Phased,SmartLifecycle,ComponentSourceAware,ExpressionCapable,OrderlyShutdownCapable,MessageProducer,IntegrationPattern,NamedComponent,IntegrationInboundManagement,IntegrationManagement,ManageableLifecycle,ManageableSmartLifecycle,TrackableComponent
public class AmqpInboundChannelAdapter
extends MessageProducerSupport
implements OrderlyShutdownCapable
Adapter that receives Messages from an AMQP Queue, converts them into
Spring Integration messages and sends the results to a Message Channel.
- Since:
- 2.1
- Author:
- Mark Fisher, Gary Russell, Artem Bilan, Ngoc Nhan
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic enumDefines the payload type when the listener container is configured with consumerBatchEnabled.protected classNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringHeader containingList<Map<String, Object>headers when batch mode isAmqpInboundChannelAdapter.BatchMode.EXTRACT_PAYLOADS_WITH_HEADERS.Fields 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
ConstructorsConstructorDescriptionAmqpInboundChannelAdapter(MessageListenerContainer listenerContainer) Construct an instance using the provided container. -
Method Summary
Modifier and TypeMethodDescriptionintCalled after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.intCalled before shutdown begins.protected voiddoStart()Take no action by default.protected voiddoStop()Take no action by default.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 created by a batching producer (such as the BatchingRabbitTemplate).voidsetBatchMode(AmqpInboundChannelAdapter.BatchMode batchMode) When the listener container is configured with consumerBatchEnabled, set the payload type for messages generated for the batches.voidsetBindSourceMessage(boolean bindSourceMessage) Set to true to bind the source message in the header namedIntegrationMessageHeaderAccessor.SOURCE_DATA.voidsetHeaderMapper(AmqpHeaderMapper headerMapper) voidsetHeaderNameForBatchedHeaders(String headerNameForBatchedHeaders) Set a header name containingList<Map<String, Object>headers when batch mode isAmqpInboundChannelAdapter.BatchMode.EXTRACT_PAYLOADS_WITH_HEADERS.voidsetMessageConverter(MessageConverter messageConverter) voidsetMessageRecoverer(MessageRecoverer messageRecoverer) Configure aMessageRecovererfor retry operations.voidsetRecoveryCallback(RecoveryCallback<?> recoveryCallback) Set aRecoveryCallbackwhen using retry within the adapter.voidsetRetryTemplate(org.springframework.core.retry.RetryTemplate retryTemplate) Set aRetryTemplateto use for retrying a message delivery within the adapter.Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, getRequiredOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisherMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
destroy, 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
destroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentNameMethods inherited from interface org.springframework.context.SmartLifecycle
isPauseable
-
Field Details
-
CONSOLIDATED_HEADERS
Header containingList<Map<String, Object>headers when batch mode isAmqpInboundChannelAdapter.BatchMode.EXTRACT_PAYLOADS_WITH_HEADERS.- See Also:
-
-
Constructor Details
-
AmqpInboundChannelAdapter
Construct an instance using the provided container.- Parameters:
listenerContainer- the container.
-
-
Method Details
-
setMessageConverter
-
setHeaderMapper
-
setRetryTemplate
public void setRetryTemplate(org.springframework.core.retry.RetryTemplate retryTemplate) Set aRetryTemplateto use for retrying a message delivery within the adapter. 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 adapter. 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 created by a batching producer (such as the BatchingRabbitTemplate). 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
-
setBatchMode
When the listener container is configured with consumerBatchEnabled, set the payload type for messages generated for the batches. Default isAmqpInboundChannelAdapter.BatchMode.MESSAGES.- Parameters:
batchMode- the batch mode.- Since:
- 5.3
-
setHeaderNameForBatchedHeaders
Set a header name containingList<Map<String, Object>headers when batch mode isAmqpInboundChannelAdapter.BatchMode.EXTRACT_PAYLOADS_WITH_HEADERS. Defaults toCONSOLIDATED_HEADERS.- Parameters:
headerNameForBatchedHeaders- the name of header containingList<Map<String, Object>headers when batch mode isAmqpInboundChannelAdapter.BatchMode.EXTRACT_PAYLOADS_WITH_HEADERS.- Since:
- 6.4
-
getComponentType
- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageProducerSupport
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classMessageProducerSupport
-
doStart
protected void doStart()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.- Overrides:
doStartin classMessageProducerSupport
-
doStop
protected void doStop()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior.- Overrides:
doStopin classMessageProducerSupport
-
beforeShutdown
public int beforeShutdown()Description copied from interface:OrderlyShutdownCapableCalled before shutdown begins. Implementations should stop accepting new messages. Can optionally return the number of active messages in process.- Specified by:
beforeShutdownin interfaceOrderlyShutdownCapable- Returns:
- The number of active messages if available.
-
afterShutdown
public int afterShutdown()Description copied from interface:OrderlyShutdownCapableCalled after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.- Specified by:
afterShutdownin interfaceOrderlyShutdownCapable- Returns:
- The number of active messages if available.
-
getErrorMessageAttributes
Description copied from class:MessageProducerSupportPopulate anAttributeAccessorto be used when building an error message with theerrorMessageStrategy.- Overrides:
getErrorMessageAttributesin classMessageProducerSupport- Parameters:
message- the message.- Returns:
- the attributes.
-