Package io.awspring.cloud.sqs.listener
Class AbstractMessageListenerContainer<T,O extends ContainerOptions<O,B>,B extends ContainerOptionsBuilder<B,O>>
java.lang.Object
io.awspring.cloud.sqs.listener.AbstractMessageListenerContainer<T,O,B>
- Type Parameters:
T- theMessagetype to be consumed by theAbstractMessageListenerContainer
- All Implemented Interfaces:
MessageListenerContainer<T>,Lifecycle,Phased,SmartLifecycle
- Direct Known Subclasses:
AbstractPipelineMessageListenerContainer
public abstract class AbstractMessageListenerContainer<T,O extends ContainerOptions<O,B>,B extends ContainerOptionsBuilder<B,O>>
extends Object
implements MessageListenerContainer<T>
Base implementation for
MessageListenerContainer with SmartLifecycle and component management
capabilities.- Since:
- 3.0
- Author:
- Tomaz Fernandes
-
Field Summary
Fields inherited from interface io.awspring.cloud.sqs.listener.MessageListenerContainer
DEFAULT_PHASE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMessageListenerContainer(O containerOptions) Create an instance with the providedContainerOptions -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessageInterceptor(AsyncMessageInterceptor<T> messageInterceptor) Add an interceptor that will intercept the message before processing.voidaddMessageInterceptor(MessageInterceptor<T> messageInterceptor) Add a collection of interceptors that will intercept the message before processing.voidReturns theContainerOptionsinstance for this container.protected voiddoStart()protected voiddoStop()Return theAcknowledgementResultCallbackinstance used by this container.Return theContainerComponentFactoryinstances to be used for creating this container's components.Return theAsyncErrorHandlerinstance used by this container.getId()Get the container id.Return theAsyncMessageInterceptorinstances used by this container.Return theAsyncMessageListenerinstance used by this container.intgetPhase()Return the queue names assigned to this container.booleanbooleanvoidsetAcknowledgementResultCallback(AcknowledgementResultCallback<T> acknowledgementResultCallback) Set theAcknowledgementResultCallbackinstance to be used by this container.voidsetAcknowledgementResultCallback(AsyncAcknowledgementResultCallback<T> acknowledgementResultCallback) Set theAsyncAcknowledgementResultCallbackinstance to be used by this container.voidsetAsyncMessageListener(AsyncMessageListener<T> asyncMessageListener) Set the listener to be used to receive messages.voidsetComponentFactories(Collection<ContainerComponentFactory<T, O>> containerComponentFactories) voidsetErrorHandler(AsyncErrorHandler<T> errorHandler) Set theAsyncErrorHandlerinstance to be used by this container.voidsetErrorHandler(ErrorHandler<T> errorHandler) Set theErrorHandlerinstance to be used by this container.voidSet the id for this container instance.voidsetMessageListener(MessageListener<T> messageListener) Set the listener to be used to process messages.voidsetPhase(int phase) Set the phase for the SmartLifecycle for this container instance.voidsetQueueNames(String... queueNames) Set the queue logical names that will be handled by the container.voidsetQueueNames(Collection<String> queueNames) Set the queue logical names that will be handled by the container.voidstart()voidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Constructor Details
-
AbstractMessageListenerContainer
Create an instance with the providedContainerOptions- Parameters:
containerOptions- the options instance.
-
-
Method Details
-
setId
Set the id for this container instance.- Specified by:
setIdin interfaceMessageListenerContainer<T>- Parameters:
id- the id.
-
setErrorHandler
Set theErrorHandlerinstance to be used by this container. The component will be adapted to anAsyncErrorHandler.- Parameters:
errorHandler- the instance.
-
setErrorHandler
Set theAsyncErrorHandlerinstance to be used by this container.- Parameters:
errorHandler- the instance.
-
addMessageInterceptor
Add a collection of interceptors that will intercept the message before processing. Interceptors are executed sequentially and in order.- Parameters:
messageInterceptor- the interceptor instances.
-
addMessageInterceptor
Add an interceptor that will intercept the message before processing. Interceptors are executed sequentially and in order.- Parameters:
messageInterceptor- the interceptor instances.
-
setMessageListener
Description copied from interface:MessageListenerContainerSet the listener to be used to process messages.- Specified by:
setMessageListenerin interfaceMessageListenerContainer<T>- Parameters:
messageListener- the instance.
-
setAsyncMessageListener
Description copied from interface:MessageListenerContainerSet the listener to be used to receive messages.- Specified by:
setAsyncMessageListenerin interfaceMessageListenerContainer<T>- Parameters:
asyncMessageListener- the message listener instance.
-
setAcknowledgementResultCallback
public void setAcknowledgementResultCallback(AsyncAcknowledgementResultCallback<T> acknowledgementResultCallback) Set theAsyncAcknowledgementResultCallbackinstance to be used by this container.- Parameters:
acknowledgementResultCallback- the instance.
-
setAcknowledgementResultCallback
public void setAcknowledgementResultCallback(AcknowledgementResultCallback<T> acknowledgementResultCallback) Set theAcknowledgementResultCallbackinstance to be used by this container.- Parameters:
acknowledgementResultCallback- the instance.
-
setComponentFactories
public void setComponentFactories(Collection<ContainerComponentFactory<T, O>> containerComponentFactories) -
setPhase
public void setPhase(int phase) Set the phase for the SmartLifecycle for this container instance.- Parameters:
phase- the phase.
-
configure
Returns theContainerOptionsinstance for this container. Changed options will take effect on container restart. -
getContainerOptions
-
getContainerComponentFactories
Return theContainerComponentFactoryinstances to be used for creating this container's components.- Returns:
- the instances.
-
getMessageListener
Return theAsyncMessageListenerinstance used by this container.- Returns:
- the instance.
-
getErrorHandler
Return theAsyncErrorHandlerinstance used by this container.- Returns:
- the instance.
-
getMessageInterceptors
Return theAsyncMessageInterceptorinstances used by this container.- Returns:
- the instances.
-
getAcknowledgementResultCallback
Return theAcknowledgementResultCallbackinstance used by this container.- Returns:
- the instance.
-
getId
Description copied from interface:MessageListenerContainerGet the container id.- Specified by:
getIdin interfaceMessageListenerContainer<T>- Returns:
- the id.
-
setQueueNames
Set the queue logical names that will be handled by the container. Required for container start.- Parameters:
queueNames- the queue names.
-
setQueueNames
Set the queue logical names that will be handled by the container. Required for container start.- Parameters:
queueNames- the queue names.
-
getQueueNames
Return the queue names assigned to this container.- Returns:
- the queue names.
-
isRunning
public boolean isRunning() -
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartupin interfaceSmartLifecycle
-
start
public void start() -
doStart
protected void doStart() -
stop
public void stop() -
doStop
protected void doStop()
-