相关疑难解决方法(0)

Spring AMQP RabbitMq中的预定/延迟消息传递

我很难在Spring AMQP/Rabbit MQ中找到预定/延迟消息的方法.
经过大量的搜索仍然无法在Spring AMQP中做到这一点.有人可以告诉我如何在Spring AMQP中进行x-delay.
如果消费者方面发生了一些异常,我想延迟消息.RabbitMQ说要添加x-delay并安装我已经完成的插件,但仍然会立即收到消息而没有任何延迟



我收到的消息已
收到<(正文:'[B @ 60a4ae5f(byte [26])'MessageProperties [headers = {x-delay = 15000}

 @Bean
ConnectionFactory connectionFactory(){

    CachingConnectionFactory connectionFactory=new CachingConnectionFactory("127.0.0.1");
    connectionFactory.setUsername("guest");
    connectionFactory.setPassword("guest");
    connectionFactory.setPort(1500);
    connectionFactory.setPublisherReturns(true);
    return connectionFactory;

}

@Bean
Binding binding(@Qualifier("queue")Queue queue, DirectExchange exchange) {
    return new Binding(queue.getName(), Binding.DestinationType.QUEUE, exchange.getName(), queue.getName(), null);
    //return BindingBuilder.bind(queue).to(exchange).with(queueName);   
}

@Bean
DirectExchange exchange() {
    DirectExchange exchange=new DirectExchange("delay-exchange");
    return exchange;
}
Run Code Online (Sandbox Code Playgroud)

消费者---
@Override

public void onMessage(Message message, Channel channel) throws Exception {

    System.out.println("Received <" + message+ ">" +rabbitTemplate);

    if(i==1){
        AMQP.BasicProperties.Builder props = …
Run Code Online (Sandbox Code Playgroud)

rabbitmq spring-amqp

5
推荐指数
1
解决办法
5909
查看次数

标签 统计

rabbitmq ×1

spring-amqp ×1