public class SimpleMessageListenerContainer extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractMessageListenerContainer.QueueAttributes |
Constructor and Description |
---|
SimpleMessageListenerContainer() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected org.springframework.core.task.AsyncTaskExecutor |
createDefaultTaskExecutor()
Create a default TaskExecutor.
|
void |
destroy() |
protected void |
doDestroy() |
protected void |
doStart() |
protected void |
doStop() |
protected void |
executeMessage(org.springframework.messaging.Message<String> stringMessage) |
protected com.amazonaws.services.sqs.AmazonSQSAsync |
getAmazonSqs() |
long |
getBackOffTime() |
protected String |
getBeanName() |
protected org.springframework.messaging.core.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 org.springframework.core.task.AsyncTaskExecutor |
getTaskExecutor() |
protected Integer |
getVisibilityTimeout() |
protected Integer |
getWaitTimeOut() |
protected void |
initialize() |
boolean |
isActive() |
boolean |
isAutoStartup() |
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(org.springframework.messaging.core.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(org.springframework.cloud.aws.core.env.ResourceIdResolver resourceIdResolver)
This value must be set if no destination resolver has been set.
|
void |
setTaskExecutor(org.springframework.core.task.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 org.springframework.core.task.AsyncTaskExecutor getTaskExecutor()
public void setTaskExecutor(org.springframework.core.task.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 10000 milliseconds (10 seconds).queueStopTimeout
- in millisecondsprotected void initialize()
protected void doStart()
protected void doStop()
protected void doDestroy()
protected org.springframework.core.task.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)
protected void executeMessage(org.springframework.messaging.Message<String> stringMessage)
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 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 org.springframework.messaging.core.DestinationResolver<String> getDestinationResolver()
public void setDestinationResolver(org.springframework.messaging.core.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 org.springframework.beans.factory.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(org.springframework.cloud.aws.core.env.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 org.springframework.context.SmartLifecycle
public void setAutoStartup(boolean autoStartup)
autoStartup
- - false if the container will be manually startedpublic void stop(Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
public int getPhase()
getPhase
in interface org.springframework.context.Phased
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 org.springframework.beans.factory.InitializingBean
Exception
public void start()
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.