public class SimpleMessageListenerContainer extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractMessageListenerContainer.QueueAttributes |
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_MAX_NUMBER_OF_MESSAGES |
DEFAULT_PHASE
Constructor and Description |
---|
SimpleMessageListenerContainer() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected AsyncTaskExecutor |
createDefaultTaskExecutor()
Create a default TaskExecutor.
|
void |
destroy() |
protected void |
doDestroy() |
protected void |
doStart() |
protected void |
doStop() |
protected void |
executeMessage(Message<String> stringMessage) |
protected com.amazonaws.services.sqs.AmazonSQSAsync |
getAmazonSqs() |
long |
getBackOffTime() |
protected String |
getBeanName() |
protected DestinationResolver<String> |
getDestinationResolver() |
protected Object |
getLifecycleMonitor() |
protected org.slf4j.Logger |
getLogger() |
protected Integer |
getMaxNumberOfMessages() |
protected QueueMessageHandler |
getMessageHandler() |
int |
getPhase() |
long |
getQueueStopTimeout() |
protected Map<String,AbstractMessageListenerContainer.QueueAttributes> |
getRegisteredQueues() |
protected AsyncTaskExecutor |
getTaskExecutor() |
protected Integer |
getVisibilityTimeout() |
protected Integer |
getWaitTimeOut() |
protected void |
initialize() |
boolean |
isActive() |
boolean |
isAutoStartup() |
protected boolean |
isQueueRunning(String logicalQueueName) |
boolean |
isRunning() |
boolean |
isRunning(String logicalQueueName)
Checks if the spinning thread for the specified queue
logicalQueueName is
still running (polling for new messages) or not. |
void |
setAmazonSqs(com.amazonaws.services.sqs.AmazonSQSAsync amazonSqs)
Configures the mandatory
AmazonSQS client for this instance. |
void |
setAutoStartup(boolean autoStartup)
Configures if this container should be automatically started.
|
void |
setBackOffTime(long backOffTime)
The number of milliseconds the polling thread must wait before trying to recover
when an error occurs (e.g.
|
void |
setBeanName(String name) |
void |
setDestinationResolver(DestinationResolver<String> destinationResolver)
Configures the destination resolver used to retrieve the queue url based on the
destination name configured for this instance.
|
void |
setMaxNumberOfMessages(Integer maxNumberOfMessages)
Configure the maximum number of messages that should be retrieved during one poll
to the Amazon SQS system.
|
void |
setMessageHandler(QueueMessageHandler messageHandler) |
void |
setPhase(int phase)
Configure a custom phase for the container to start.
|
void |
setQueueStopTimeout(long queueStopTimeout)
The number of milliseconds the
stop(String)
method waits for a queue to stop before interrupting the current thread. |
void |
setResourceIdResolver(ResourceIdResolver resourceIdResolver)
This value must be set if no destination resolver has been set.
|
void |
setTaskExecutor(AsyncTaskExecutor taskExecutor) |
void |
setVisibilityTimeout(Integer visibilityTimeout)
Configures the duration (in seconds) that the received messages are hidden from
subsequent poll requests after being retrieved from the system.
|
void |
setWaitTimeOut(Integer waitTimeOut)
Configures the wait timeout that the poll request will wait for new message to
arrive if the are currently no messages on the queue.
|
void |
start() |
void |
start(String logicalQueueName) |
protected void |
startQueue(String queueName,
AbstractMessageListenerContainer.QueueAttributes queueAttributes) |
void |
stop() |
void |
stop(Runnable callback) |
void |
stop(String logicalQueueName)
Stops and waits until the specified queue has stopped.
|
protected void |
stopQueue(String logicalQueueName) |
protected static final int DEFAULT_MAX_NUMBER_OF_MESSAGES
protected AsyncTaskExecutor getTaskExecutor()
public void setTaskExecutor(AsyncTaskExecutor taskExecutor)
public long getBackOffTime()
public void setBackOffTime(long backOffTime)
backOffTime
- in millisecondspublic long getQueueStopTimeout()
stop(String)
method waits for a queue to
stop before interrupting the current thread. Default value is 10000 milliseconds
(10 seconds).public void setQueueStopTimeout(long queueStopTimeout)
stop(String)
method waits for a queue to stop before interrupting the current thread. Default
value is 20000 milliseconds (20 seconds).queueStopTimeout
- in millisecondsprotected void initialize()
protected void doStart()
protected void doStop()
protected void doDestroy()
protected AsyncTaskExecutor createDefaultTaskExecutor()
The default implementation builds a
SimpleAsyncTaskExecutor
with the specified
bean name (or the class name, if no bean name specified) as thread name prefix.
SimpleAsyncTaskExecutor
configured
with the thread name prefixSimpleAsyncTaskExecutor.SimpleAsyncTaskExecutor(String)
public void stop(String logicalQueueName)
getQueueStopTimeout()
is
reached, the current thread is interrupted.logicalQueueName
- the name as defined on the listener methodprotected void stopQueue(String logicalQueueName)
public void start(String logicalQueueName)
public boolean isRunning(String logicalQueueName)
logicalQueueName
is
still running (polling for new messages) or not.logicalQueueName
- the name as defined on the listener methodtrue
if the spinning thread for the specified queue is running
otherwise false
.protected void startQueue(String queueName, AbstractMessageListenerContainer.QueueAttributes queueAttributes)
protected boolean isQueueRunning(String logicalQueueName)
protected Map<String,AbstractMessageListenerContainer.QueueAttributes> getRegisteredQueues()
protected QueueMessageHandler getMessageHandler()
public void setMessageHandler(QueueMessageHandler messageHandler)
protected Object getLifecycleMonitor()
protected org.slf4j.Logger getLogger()
protected com.amazonaws.services.sqs.AmazonSQSAsync getAmazonSqs()
public void setAmazonSqs(com.amazonaws.services.sqs.AmazonSQSAsync amazonSqs)
AmazonSQS
client for this instance.
Note:The configured instance should have a buffering amazon SQS instance
(see subclasses) functionality to improve the performance during message reception
and deletion on the queueing system.amazonSqs
- the amazon sqs instance. Must not be nullprotected DestinationResolver<String> getDestinationResolver()
public void setDestinationResolver(DestinationResolver<String> destinationResolver)
DestinationResolver
must
be provided. (For example if one want to have the
DynamicQueueUrlDestinationResolver
with the auto creation of queues set to
true
.destinationResolver
- - the destination resolver. Must not be nullprotected String getBeanName()
public void setBeanName(String name)
setBeanName
in interface BeanNameAware
protected Integer getMaxNumberOfMessages()
public void setMaxNumberOfMessages(Integer maxNumberOfMessages)
maxNumberOfMessages
- the maximum number of messages (between 1-10)protected Integer getVisibilityTimeout()
public void setVisibilityTimeout(Integer visibilityTimeout)
visibilityTimeout
- the visibility timeout in secondspublic void setResourceIdResolver(ResourceIdResolver resourceIdResolver)
resourceIdResolver
- the resourceIdResolver to use for resolving logical to
physical ids in a CloudFormation environment. Must not be null.protected Integer getWaitTimeOut()
public void setWaitTimeOut(Integer waitTimeOut)
waitTimeOut
- - the wait time out in secondspublic boolean isAutoStartup()
isAutoStartup
in interface SmartLifecycle
public void setAutoStartup(boolean autoStartup)
autoStartup
- - false if the container will be manually startedpublic void stop(Runnable callback)
stop
in interface SmartLifecycle
public int getPhase()
getPhase
in interface Phased
getPhase
in interface SmartLifecycle
public void setPhase(int phase)
SmartLifecycle
interface.phase
- - the phase that defines the phase respecting the
Ordered
semanticspublic boolean isActive()
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public void destroy()
destroy
in interface DisposableBean
Copyright © 2021 Pivotal Software, Inc.. All rights reserved.