public class BlockingQueueConsumer
extends java.lang.Object
| Constructor and Description |
|---|
BlockingQueueConsumer(ConnectionFactory connectionFactory,
MessagePropertiesConverter messagePropertiesConverter,
ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter,
org.springframework.amqp.core.AcknowledgeMode acknowledgeMode,
boolean transactional,
int prefetchCount,
boolean defaultRequeueRejected,
java.util.Map<java.lang.String,java.lang.Object> consumerArgs,
boolean noLocal,
boolean exclusive,
java.lang.String... queues)
Create a consumer.
|
BlockingQueueConsumer(ConnectionFactory connectionFactory,
MessagePropertiesConverter messagePropertiesConverter,
ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter,
org.springframework.amqp.core.AcknowledgeMode acknowledgeMode,
boolean transactional,
int prefetchCount,
boolean defaultRequeueRejected,
java.util.Map<java.lang.String,java.lang.Object> consumerArgs,
boolean exclusive,
java.lang.String... queues)
Create a consumer.
|
BlockingQueueConsumer(ConnectionFactory connectionFactory,
MessagePropertiesConverter messagePropertiesConverter,
ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter,
org.springframework.amqp.core.AcknowledgeMode acknowledgeMode,
boolean transactional,
int prefetchCount,
boolean defaultRequeueRejected,
java.util.Map<java.lang.String,java.lang.Object> consumerArgs,
java.lang.String... queues)
Create a consumer.
|
BlockingQueueConsumer(ConnectionFactory connectionFactory,
MessagePropertiesConverter messagePropertiesConverter,
ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter,
org.springframework.amqp.core.AcknowledgeMode acknowledgeMode,
boolean transactional,
int prefetchCount,
boolean defaultRequeueRejected,
java.lang.String... queues)
Create a consumer.
|
BlockingQueueConsumer(ConnectionFactory connectionFactory,
MessagePropertiesConverter messagePropertiesConverter,
ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter,
org.springframework.amqp.core.AcknowledgeMode acknowledgeMode,
boolean transactional,
int prefetchCount,
java.lang.String... queues)
Create a consumer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
basicCancel() |
protected void |
basicCancel(boolean expected) |
protected boolean |
cancelled() |
void |
clearDeliveryTags()
Clear the delivery tags when rolling back with an external transaction
manager.
|
boolean |
commitIfNecessary(boolean localTx)
Perform a commit or message acknowledgement, as appropriate.
|
org.springframework.util.backoff.BackOffExecution |
getBackOffExecution() |
com.rabbitmq.client.Channel |
getChannel() |
java.util.Collection<java.lang.String> |
getConsumerTags() |
protected boolean |
hasDelivery() |
boolean |
isNormalCancel()
Return true if cancellation is expected.
|
org.springframework.amqp.core.Message |
nextMessage()
Main application-side API: wait for the next message delivery and return it.
|
org.springframework.amqp.core.Message |
nextMessage(long timeout)
Main application-side API: wait for the next message delivery and return it.
|
void |
rollbackOnExceptionIfNecessary(java.lang.Throwable ex)
Perform a rollback, handling rollback exceptions properly.
|
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
void |
setBackOffExecution(org.springframework.util.backoff.BackOffExecution backOffExecution)
Set the
BackOffExecution to use for the recovery in the SimpleMessageListenerContainer. |
void |
setConsumeDelay(long consumeDelay)
Set the consumeDelay - a time to wait before consuming in ms.
|
void |
setDeclarationRetries(int declarationRetries)
Set the number of retries after passive queue declaration fails.
|
void |
setFailedDeclarationRetryInterval(long failedDeclarationRetryInterval)
Set the interval between passive queue declaration attempts in milliseconds.
|
void |
setGlobalQos(boolean globalQos)
Apply prefetch to the entire channel.
|
void |
setLocallyTransacted(boolean locallyTransacted)
True if the channel is locally transacted.
|
void |
setMissingQueuePublisher(java.util.function.Consumer<java.lang.String> missingQueuePublisher)
Set the publisher for a missing queue event.
|
void |
setRetryDeclarationInterval(long retryDeclarationInterval)
When consuming multiple queues, set the interval between declaration attempts when only
a subset of the queues were available (milliseconds).
|
void |
setShutdownTimeout(long shutdownTimeout) |
void |
setTagStrategy(org.springframework.amqp.support.ConsumerTagStrategy tagStrategy)
Set the
ConsumerTagStrategy to use when generating consumer tags. |
void |
start() |
void |
stop() |
java.lang.String |
toString() |
public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, org.springframework.amqp.core.AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, java.lang.String... queues)
connectionFactory - The connection factory.messagePropertiesConverter - The properties converter.activeObjectCounter - The active object counter; used during shutdown.acknowledgeMode - The acknowledgemode.transactional - Whether the channel is transactional.prefetchCount - The prefetch count.queues - The queues.public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, org.springframework.amqp.core.AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, java.lang.String... queues)
connectionFactory - The connection factory.messagePropertiesConverter - The properties converter.activeObjectCounter - The active object counter; used during shutdown.acknowledgeMode - The acknowledge mode.transactional - Whether the channel is transactional.prefetchCount - The prefetch count.defaultRequeueRejected - true to reject requeued messages.queues - The queues.public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, org.springframework.amqp.core.AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, @Nullable java.util.Map<java.lang.String,java.lang.Object> consumerArgs, java.lang.String... queues)
connectionFactory - The connection factory.messagePropertiesConverter - The properties converter.activeObjectCounter - The active object counter; used during shutdown.acknowledgeMode - The acknowledge mode.transactional - Whether the channel is transactional.prefetchCount - The prefetch count.defaultRequeueRejected - true to reject requeued messages.consumerArgs - The consumer arguments (e.g. x-priority).queues - The queues.public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, org.springframework.amqp.core.AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, @Nullable java.util.Map<java.lang.String,java.lang.Object> consumerArgs, boolean exclusive, java.lang.String... queues)
connectionFactory - The connection factory.messagePropertiesConverter - The properties converter.activeObjectCounter - The active object counter; used during shutdown.acknowledgeMode - The acknowledge mode.transactional - Whether the channel is transactional.prefetchCount - The prefetch count.defaultRequeueRejected - true to reject requeued messages.consumerArgs - The consumer arguments (e.g. x-priority).exclusive - true if the consumer is to be exclusive.queues - The queues.public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, org.springframework.amqp.core.AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, @Nullable java.util.Map<java.lang.String,java.lang.Object> consumerArgs, boolean noLocal, boolean exclusive, java.lang.String... queues)
connectionFactory - The connection factory.messagePropertiesConverter - The properties converter.activeObjectCounter - The active object counter; used during shutdown.acknowledgeMode - The acknowledge mode.transactional - Whether the channel is transactional.prefetchCount - The prefetch count.defaultRequeueRejected - true to reject requeued messages.consumerArgs - The consumer arguments (e.g. x-priority).noLocal - true if the consumer is to be no-local.exclusive - true if the consumer is to be exclusive.queues - The queues.public com.rabbitmq.client.Channel getChannel()
public java.util.Collection<java.lang.String> getConsumerTags()
public void setShutdownTimeout(long shutdownTimeout)
public void setDeclarationRetries(int declarationRetries)
declarationRetries - The number of retries, default 3.setFailedDeclarationRetryInterval(long)public void setFailedDeclarationRetryInterval(long failedDeclarationRetryInterval)
failedDeclarationRetryInterval - the interval, default 5000.setDeclarationRetries(int)public void setRetryDeclarationInterval(long retryDeclarationInterval)
retryDeclarationInterval - the interval, default 60000.public void setTagStrategy(org.springframework.amqp.support.ConsumerTagStrategy tagStrategy)
ConsumerTagStrategy to use when generating consumer tags.tagStrategy - the tagStrategy to setpublic void setBackOffExecution(org.springframework.util.backoff.BackOffExecution backOffExecution)
BackOffExecution to use for the recovery in the SimpleMessageListenerContainer.backOffExecution - the backOffExecution.public org.springframework.util.backoff.BackOffExecution getBackOffExecution()
public void setLocallyTransacted(boolean locallyTransacted)
locallyTransacted - the locally transacted to set.public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
public void setMissingQueuePublisher(java.util.function.Consumer<java.lang.String> missingQueuePublisher)
missingQueuePublisher - the publisher.public void setConsumeDelay(long consumeDelay)
concurrency > 1, to avoid uneven distribution of
consumers across the shards. See the plugin README for more information.consumeDelay - the consume delay.public void clearDeliveryTags()
public void setGlobalQos(boolean globalQos)
globalQos - true for a channel-wide prefetch.Channel.basicQos(int, boolean)public boolean isNormalCancel()
protected void basicCancel()
protected void basicCancel(boolean expected)
protected boolean hasDelivery()
protected boolean cancelled()
@Nullable
public org.springframework.amqp.core.Message nextMessage()
throws java.lang.InterruptedException,
com.rabbitmq.client.ShutdownSignalException
java.lang.InterruptedException - if an interrupt is received while waitingcom.rabbitmq.client.ShutdownSignalException - if the connection is shut down while waiting@Nullable
public org.springframework.amqp.core.Message nextMessage(long timeout)
throws java.lang.InterruptedException,
com.rabbitmq.client.ShutdownSignalException
timeout - timeout in millisecondjava.lang.InterruptedException - if an interrupt is received while waitingcom.rabbitmq.client.ShutdownSignalException - if the connection is shut down while waitingpublic void start()
throws org.springframework.amqp.AmqpException
org.springframework.amqp.AmqpExceptionpublic void stop()
public void rollbackOnExceptionIfNecessary(java.lang.Throwable ex)
ex - the thrown application exception or errorpublic boolean commitIfNecessary(boolean localTx)
throws java.io.IOException
localTx - Whether the channel is locally transacted.java.io.IOException - Any IOException.public java.lang.String toString()
toString in class java.lang.Object