4.4. Writing Publish/Subscribe Applications in Python

4.4. Writing Publish/Subscribe Applications in Python

This section describes two sample programs that implement a Publish/Subscribe application using a topic exchange. Topic exchanges deliver messages based on multi-part routing keys and binding keys that may contain wildcards.

In this example, the publisher creates messages for topics like news, weather, and sports that happen in regions like Europe, Asia, or the United States. A given consumer may be interested in all weather messages, regardless of region, or it may be interested in news and weather for the United States, but uninterested in items for other regions. In this example, each consumer sets up its own private queues, which receive precisely the messages that particular consumer is interested in.