Complete the code to send a message using Spring Boot's messaging template.
messagingTemplate.[1]("topicName", "Hello World");
The convertAndSend method is used to send messages to a destination in Spring Boot messaging.
Complete the code to define a message listener method in a Spring Boot component.
@[1]("/topic/greetings") public void receiveMessage(String message) { System.out.println(message); }
The @MessageMapping annotation maps incoming messages to the method in Spring Boot messaging.
Fix the error in the method to correctly send a message asynchronously.
public void sendAsyncMessage(String destination, String msg) {
messagingTemplate.[1](destination, msg);
}The convertAndSend method converts the message and sends it asynchronously in Spring Boot messaging.
Fill both blanks to create a message listener that listens to a topic and sends a response.
@[1]("/app/hello") @SendTo("/topic/greetings") public String greet(String name) { return "Hello, " + [2] + "!"; }
The method listens to messages mapped by @MessageMapping and uses the parameter name to create a greeting.
Fill all three blanks to configure a simple message broker in Spring Boot.
@Override public void configureMessageBroker([1] registry) { registry.[2]("/topic"); registry.[3]("/app"); }
The method parameter is MessageBrokerRegistry. The enableSimpleBroker sets the topic prefix, and setApplicationDestinationPrefixes sets the application prefix.