RabbitMQ 메시지 보내기 후 반환 메시지 얻기

1964 단어 MQ
생산자
@Autowired
private AmqpTemplate rabbitTemplate;

public Object sendAndReceive(String exchange, String routineKey, Object content) {
        Object obj = rabbitTemplate.convertSendAndReceive(exchange, routineKey, content);
        return obj;
    }

@RequestMapping("/demo")
public String demo() {
    for (int i=0;i<20;i++){
        Object a =  sendAndReceive(RabbitContants.INVENTORY,String.valueOf(i));
        System.out.println("++++++++  "+a+"   +++++++++");
    }
    return "33334";
}

소비자
 @RabbitListener(queues = RabbitContants.INVENTORY)
 @SendTo( RabbitContants.INVENTORY)
 public String moulds(String message){
     System.out.println("============"+message+"=============");
     return message+"b";
 }

출력 ===================================================================+++===============================================================================================================================================++++ 3b+++++++====================================+++++ 4b++++++

좋은 웹페이지 즐겨찾기