liveBook · Manning

Asynchronous programming

As explained in Spring in Action, Sixth Edition

Asynchronous communication is interapplication communication in which the sender can continue processing without waiting for the recipient's response.

Asynchronous programming lets one application send a message without waiting for the recipient to respond. A broker holds and relays the message, allowing the sender to continue while the consumer reads it later. This indirection reduces coupling and can improve scalability compared with synchronous request-response communication. section 9.0 section 14.0

Sending an order to a kitchen

A Taco Cloud website sends an order to a separate kitchen application. The website does not wait for the kitchen to finish preparing the tacos; it places the message with a broker so the kitchen can consume it when ready. The same pattern resembles sending an email before leaving for vacation: delivery and reading happen later, while the sender continues. section 9.0

Spring supports asynchronous messaging through several broker and consumption styles:

  • JMS provides a common Java API for message brokers; Spring exposes it through JmsTemplate and message-driven POJOs. section 9.1
  • RabbitMQ and Apache Kafka provide alternative messaging platforms supported by Spring template clients. section 9.4
  • Consumers can pull messages with template clients or receive pushed messages through @JmsListener, @RabbitListener, or @KafkaListener methods. section 9.4

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains indirection, brokers, templates, consumers, and listener annotations without detailing message-processing internals.
Examples
Uses email delivery and Taco Cloud order routing as examples of send-now, receive-later communication.
What it assumes
Contrasts asynchronous messaging with familiar REST request-response communication and introduces brokers before implementation.
What you can do after
Apply it via Spring JmsTemplate, RabbitTemplate, KafkaTemplate, or message-listener annotations.
How it connects
Connects asynchronous messaging with message brokers, JMS, RabbitMQ, Kafka, Spring, REST, and request-response communication.

Also explained in

Compare how 28 books explain asynchronous programming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.