1
回答
springboot+rabbitmq问题
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

spring boot + rabbitmq  两次请求为什么只能接收到一次参数

controller

@RequestMapping("/rabbitMq")
public void send() {
    rabbitTemplate.convertSendAndReceive("hello", "第一次请求");
    rabbitTemplate.convertSendAndReceive("hello","第二次请求");

    System.out.println("111111");
}

 

@Component
@RabbitListener(queues = "hello")
public class Receiver {

    @RabbitHandler
    public void processMessage(String msg) throws Exception {
        System.out.println(msg);
    }

config配置

@Configuration
public class RabbitConfig {

    //声明队列
    @Bean
    public Queue queue1() {
        // true表示持久化该队列
        return new Queue("hello");
    }

    @Bean
    TopicExchange topicExchange() {
        return new TopicExchange("topicExchange");
    }

    //绑定
    @Bean
    public Binding binding1(Queue queue, TopicExchange topicExchange) {
        return BindingBuilder.bind(queue).to(topicExchange).with("key.1");
    }

    //绑定
    @Bean
    public AsyncRabbitTemplate tt(ConnectionFactory connectionFactory) {
        return new AsyncRabbitTemplate(connectionFactory, "topicExchange", "key.1", "hello");
    }
}

求解............................................................................

举报
桑灬桑
发帖于1周前 1回/63阅
顶部