I have been looking for a solution since morning. Why is it returning null rather than an Object? Any ideas
Consumer part takes the message but the response is Null with the convertSendAndReceive()
method.
RabbitMQProducer.java
private static final long DEFAULT_REPLY_TIMEOUT = 10000;
public Object sendJsonMessage(Card card){
rabbitTemplate.setReplyTimeout(DEFAULT_REPLY_TIMEOUT);
log.info(String.format("Message sent -> %s", card.toString()));
return rabbitTemplate.convertSendAndReceive(exchange,routingKey, card);
}
Controller
@PostMapping("/addCards")
public ResponseEntity <String> addCards(@Valid @RequestBody Card card ){
Object object = producer.sendJsonMessage(card);
System.out.println( "OBJECT :" + object);
return ResponseEntity.ok("Json message sent to RabbitMQ ..." + card.getFirstName());
}
Output
OBJECT :null