Pand005
Pand005

Reputation: 1175

How to configure rabbitmq reply queues using spring-amqp?

We are trying to make asynchronous call in RabbitMQ using Spring AMQP, could any one please tell me how to configure replyqueue, correlationId, (properties) using spring amqp?

    String corrId = java.util.UUID.randomUUID().toString();

 BasicProperties props = new BasicProperties
                                .Builder()
                                .correlationId(corrId)
                                .replyTo(replyQueueName)
                                .build();

 channel.basicPublish("", requestQueueName, props, message.getBytes());

Upvotes: 0

Views: 1944

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121560

I assume you need to use RabbitTemplate:

rabbitTemplate.convertAndSend(requestQueueName, myObj, new MessagePostProcessor() {
   Message postProcessMessage(Message message) throws AmqpException {
      message.getMessageProperties().setReplyTo(replyQueueName);
      return message;  
   }
}, new CorrelationData(corrId));

HTH

Upvotes: 1

Related Questions