Example usage for org.springframework.amqp.rabbit.listener BlockingQueueConsumer BlockingQueueConsumer

List of usage examples for org.springframework.amqp.rabbit.listener BlockingQueueConsumer BlockingQueueConsumer

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.listener BlockingQueueConsumer BlockingQueueConsumer.

Prototype

public BlockingQueueConsumer(ConnectionFactory connectionFactory,
        MessagePropertiesConverter messagePropertiesConverter,
        ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode,
        boolean transactional, int prefetchCount, boolean defaultRequeueRejected,
        @Nullable Map<String, Object> consumerArgs, boolean exclusive, String... queues) 

Source Link

Document

Create a consumer.

Usage

From source file:org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.java

protected BlockingQueueConsumer createBlockingQueueConsumer() {
    BlockingQueueConsumer consumer;/*from   w w w  .j  a v  a2 s .  c  o m*/
    String[] queues = getRequiredQueueNames();
    // There's no point prefetching less than the tx size, otherwise the consumer will stall because the broker
    // didn't get an ack for delivered messages
    int actualPrefetchCount = getPrefetchCount() > this.txSize ? getPrefetchCount() : this.txSize;
    consumer = new BlockingQueueConsumer(getConnectionFactory(), this.messagePropertiesConverter,
            this.cancellationLock, getAcknowledgeMode(), isChannelTransacted(), actualPrefetchCount,
            isDefaultRequeueRejected(), getConsumerArguments(), isExclusive(), queues);
    if (this.declarationRetries != null) {
        consumer.setDeclarationRetries(this.declarationRetries);
    }
    if (this.failedDeclarationRetryInterval != null) {
        consumer.setFailedDeclarationRetryInterval(this.failedDeclarationRetryInterval);
    }
    if (this.retryDeclarationInterval != null) {
        consumer.setRetryDeclarationInterval(this.retryDeclarationInterval);
    }
    if (getConsumerTagStrategy() != null) {
        consumer.setTagStrategy(getConsumerTagStrategy());
    }
    consumer.setBackOffExecution(this.recoveryBackOff.start());
    consumer.setShutdownTimeout(getShutdownTimeout());
    return consumer;
}