← Back to the chapter · Previous detail

Technical detail · AMQP Core: Consumers and Topology Contracts

Test the alternate route honestly

Configure factory-alerts with durable=True and arguments={'alternate-exchange': 'unrouted-alerts'} when it is first declared. Redeclaring the existing exchange later with different arguments is not a safe configuration update. Declare unrouted-alerts as fanout, declare alert-deadletter, and bind that queue to the alternate exchange. Run this setup before publishing any alerts:

channel.exchange_declare(exchange='unrouted-alerts', exchange_type='fanout')
channel.queue_declare(queue='alert-deadletter')
channel.queue_bind(exchange='unrouted-alerts', queue='alert-deadletter')

The apparently unfamiliar key alert.unknown.line99.machine00 still matches maintenance’s alert.#. It therefore goes to maintenance rather than exercising the alternate route. A zero-match test must actually miss every primary binding. Record the deployed binding set with the test, rather than assuming an unfamiliar severity or line makes a key unroutable.

← Back to the chapter · Previous detail