4.3.3. Publishing Messages to the Fanout Exchange

4.3.3. Publishing Messages to the Fanout Exchange

The message producer publishes its messages to the amq.fanout exchange. There is no need for a routing key, but iot will still be shown in message logs and on the message received by a client, where it can be useful for identifying the sender for debugging purposes.

delivery_properties = session.delivery_properties(routing_key="routing_key")

for i in range(10):
     session.message_transfer(destination="amq.fanout", message=Message(delivery_properties,"message " + str(i)))

session.message_transfer(destination="amq.fanout", message=Message(delivery_properties, "That's all, folks!"))