concept JmsTemplate in category spring

This is an excerpt from Manning's book Spring in Action, Fifth Edition.
Spring supports JMS through a template-based abstraction known as JmsTemplate. Using JmsTemplate, it’s easy to send messages across queues and topics from the producer side and to receive those messages on the consumer side. Spring also supports the notion of message-driven POJOs: simple Java objects that react to messages arriving on a queue or topic in an asynchronous fashion.
We’re going to explore Spring’s JMS support, including JmsTemplate and message-driven POJOs. But before you can send and receive messages, you need a message broker that’s ready to relay those messages between producers and consumers. Let’s kick off our exploration of Spring JMS by setting up a message broker in Spring.
JmsTemplate offers several methods for pulling methods from the broker, including the following:
Message receive() throws JmsException; Message receive(Destination destination) throws JmsException; Message receive(String destinationName) throws JmsException; Object receiveAndConvert() throws JmsException; Object receiveAndConvert(Destination destination) throws JmsException; Object receiveAndConvert(String destinationName) throws JmsException;As you can see, these six methods mirror the send() and convertAndSend() methods from JmsTemplate. The receive() methods receive a raw Message, whereas the receiveAndConvert() methods use a configured message converter to convert messages into domain types. And for each of these, you can specify either a Destination or a String containing the destination name, or you can pull a message from the default destination.
Aside from the unique method signatures for send() and sendDefault(), KafkaTemplate differs from JmsTemplate and RabbitTemplate in that it doesn’t offer any methods for receiving messages. That means the only way to consume messages from a Kafka topic using Spring is to write a message listener.