Chapter 5. Don’t get messages; consume them

 

This chapter covers

  • Consuming messages
  • Tuning consumer throughput
  • When consumers and queues are exclusive
  • Specifying a quality of service for your consumers

Having gone deep into the world of message publishers in the last chapter, it’s now time to talk about consuming the messages your publishers are sending. Consumer applications can be dedicated applications with the sole purpose of receiving messages and acting on them, or receiving messages may be a very small part of a much bigger application. For example, if you’re implementing an RPC pattern with RabbitMQ, the application publishing an RPC request is also consuming the RPC reply (figure 5.1).

Figure 5.1. An RPC publisher that publishes a message to RabbitMQ and waits as a consumer for the RPC reply from the RPC consumer

With so many patterns available for implementing messaging in your applications, it’s only appropriate that RabbitMQ has various settings for finding the right balance between performance and reliable messaging. Deciding how your applications will consume messages is the first step in finding this balance, and it starts off with one easy choice: Do you get messages, or do you consume messages? In this chapter you’ll learn

  • Why you should avoid getting messages in favor of consuming them
  • How to balance message delivery guarantees with delivery performance
  • How to use RabbitMQ’s per-queue settings to automatically delete queues, limit the age of messages, and more

5.1. Basic.Get vs. Basic.Consume

5.2. Performance-tuning consumers

5.3. Rejecting messages

5.4. Controlling queues

5.5. Summary

sitemap