Complete the code to send a message using RabbitTemplate.
rabbitTemplate.[1]("myQueue", "Hello World!");
send without converting the object.receive to send messages.The convertAndSend method sends a message converting the object to a message format.
Complete the code to send a message to a specific exchange with a routing key.
rabbitTemplate.convertAndSend("myExchange", [1], "Message content");
The second parameter is the routing key used to route the message to the correct queue.
Fix the error in sending a message with RabbitTemplate by completing the method call.
rabbitTemplate.[1]("exchange", "key", new Message("data".getBytes()));
convertAndSend with a Message object.sendMessage.The send method sends a raw Message object to the exchange with the routing key.
Fill both blanks to send a JSON string message with a custom header.
MessageProperties props = new MessageProperties(); props.setHeader("content-type", [1]); Message msg = new Message([2].getBytes(), props); rabbitTemplate.send("exchange", "routingKey", msg);
The header content-type should be set to application/json for JSON data. The message body is a JSON string.
Fill all three blanks to send a message with a custom exchange, routing key, and message body.
String exchange = [1]; String routingKey = [2]; String message = [3]; rabbitTemplate.convertAndSend(exchange, routingKey, message);
Use the custom exchange and routing key strings, and a message string to send with convertAndSend.