Rabbit mQ消息从就绪队列移动到Unack队列

时间:2016-10-12 03:35:01

标签: rabbitmq spring-rabbit rabbitmq-exchange spring-rabbitmq

我有一个单独的发布者和消费者。我开始发布并发布消息。现在我开始使用消费者,问题是消息从就绪队列移动到unack队列,将消息标记为redeivered,我想避免。所以我想要什么只有当我发送确认而不是消费者重新启动或启动

时才应将其标记为重新传送

配置:

@Bean
public org.springframework.amqp.rabbit.connection.Connection mqConnection() {
    CloudFactory cloudFactory = new CloudFactory();
    Cloud cloud = cloudFactory.getCloud();
    return cloud.getServiceConnector("mqservicename", ConnectionFactory.class,
            null).createConnection();
} 
@Bean
public StatefulRetryOperationsInterceptor interceptor() {
        return RetryInterceptorBuilder.stateful().retryOperations(retryTemplate()).recoverer(new RejectAndDontRequeueRecoverer())

            .build();
}
@Bean
public SimpleMessageListenerContainer listenerContainer() {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setMessageListener(new MessageListenerAdapter());
    container.setAdviceChain(new Advice[] {
           interceptor()
    });

    return container;
}



@Bean
public RetryTemplate retryTemplate(){
    Map map=new HashMap<Class<? extends Throwable>, Boolean>();
    map.put(CustomException.class, true);
    RetryTemplate retryTemplate=new RetryTemplate();
    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(3,map));
    return retryTemplate;
}

1 个答案:

答案 0 :(得分:0)

如果您使用的是Spring AMQP,则需要在提出类似问题时显示您的配置。

如果您将确认模式设置为MANUAL,则您需要负责。阅读the documentation。对于AUTO ackmode,容器将在侦听器正常返回时响应消息。

相关问题