A message handler subscribes to a queue and processes messages or events. An application typically uses a handler for each message type, such as a handler that saves new to-do items to a database. section 21.3
The queue buffers work when incoming activity spikes. Multiple handler containers can share messages, limiting concurrent processing; messages wait in the queue if handlers cannot keep up. Because processing happens asynchronously, a saved item may not appear immediately: the application reaches eventual consistency after its messages are handled. section 21.3
Handlers also let applications add event-driven features without changing the publisher:
- Add a separate audit handler to log each new item while the existing handler saves it to SQL. section 21.4
- Other possible responses include saving items to Elasticsearch for querying or adding reminders to Google Calendar. section 21.4
# run the audit message handler, keeping the same scale # for the save handler: docker compose -f docker-compose.yml ` -f docker-compose-audit.yml up -d --scale save-handler=3 # check that the audit handler is listening: docker logs todo-list-audit-handler-1 # browse to http:/./localhost:8080 and add some new items # check the audit trail: docker logs todo-list-audit-handler-1
Use the Compose override to start an audit handler, keep the save handler scaled, and inspect the audit log as items are added. section 21.4





















