2013년 10월 15일 화요일

RabbitMQ prefetchCount and txSize in spring-rabbit

 Due to following implementation in SimpleMessageListenerContainer of spring-rabbit(1.1.2-RELEASE at this point) library, you should always change txSize as well if you want to decrease prefetchCount for some reason, otherwise txSize will override prefetchCount value.

    protected BlockingQueueConsumer createBlockingQueueConsumer() {
        BlockingQueueConsumer consumer;
        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 = prefetchCount > txSize ? prefetchCount : txSize;
        consumer = new BlockingQueueConsumer(getConnectionFactory(), this.messagePropertiesConverter, cancellationLock,
                getAcknowledgeMode(), isChannelTransacted(), actualPrefetchCount, this.defaultRequeueRejected, queues);
        return consumer;
    }


댓글 없음:

댓글 쓰기

가장 많이 본 글