0
0
Spring Bootframework~10 mins

Why messaging matters in Spring Boot - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to send a message using Spring Boot's messaging template.

Spring Boot
messagingTemplate.[1]("topicName", "Hello World");
Drag options to blanks, or click blank then click option'
AconvertAndSend
Bconnect
Clisten
Dreceive
Attempts:
3 left
💡 Hint
Common Mistakes
Using receive instead of convertAndSend
Using listen which is for receiving messages
2fill in blank
medium

Complete the code to define a message listener method in a Spring Boot component.

Spring Boot
@[1]("/topic/greetings")
public void receiveMessage(String message) {
    System.out.println(message);
}
Drag options to blanks, or click blank then click option'
ASendMapping
BSubscribeMapping
CMessageMapping
DEventListener
Attempts:
3 left
💡 Hint
Common Mistakes
Using @SendMapping which is not a valid annotation
Confusing with @EventListener which is for events
3fill in blank
hard

Fix the error in the method to correctly send a message asynchronously.

Spring Boot
public void sendAsyncMessage(String destination, String msg) {
    messagingTemplate.[1](destination, msg);
}
Drag options to blanks, or click blank then click option'
AsendAsync
BconvertAndSend
CsendMessage
DasyncSend
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendAsync which does not exist
Using sendMessage which is not a Spring method
4fill in blank
hard

Fill both blanks to create a message listener that listens to a topic and sends a response.

Spring Boot
@[1]("/app/hello")
@SendTo("/topic/greetings")
public String greet(String name) {
    return "Hello, " + [2] + "!";
}
Drag options to blanks, or click blank then click option'
AMessageMapping
Bname
CSendMapping
Dmessage
Attempts:
3 left
💡 Hint
Common Mistakes
Using @SendMapping which is invalid
Using wrong parameter name in return statement
5fill in blank
hard

Fill all three blanks to configure a simple message broker in Spring Boot.

Spring Boot
@Override
public void configureMessageBroker([1] registry) {
    registry.[2]("/topic");
    registry.[3]("/app");
}
Drag options to blanks, or click blank then click option'
AMessageBrokerRegistry
BenableSimpleBroker
CsetApplicationDestinationPrefixes
DMessageMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter type
Confusing method names
Missing prefixes