File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22"""A simple RabbitMQ message publisher for local testing.
3- Takes a 'routing key' and sends a message to the 'expected' AS exchange
4- on a localhost RabbitMQ server. The AMPQ URL is specified below and is expected
3+
4+ Takes a 'routing key' and sends a built-in message to the 'event-streams' AS exchange
5+ on a RabbitMQ server. The AMPQ URL is specified below and is expected
56to match the ESS_AMPQ_URL value used in the project's docker-compose file.
67It can be changed by providing a second argument on the command line.
78
4849
4950async def main () -> None :
5051 """Publish a message."""
52+ body_str : str = f"{ _MESSAGE_CLASS } |{ _MESSAGE_STRING } "
53+ print (f"Sending { body_str } (to { _AMPQ_URL } )..." )
54+
5155 connection = await aio_pika .connect_robust (_AMPQ_URL )
5256 async with connection :
5357 channel = await connection .channel ()
@@ -58,7 +62,7 @@ async def main() -> None:
5862 durable = True ,
5963 )
6064 await es_exchange .publish (
61- aio_pika .Message (body = f" { _MESSAGE_CLASS } | { _MESSAGE_STRING } " .encode ()),
65+ aio_pika .Message (body_str .encode ()),
6266 routing_key = _ROUTING_KEY ,
6367 )
6468
You can’t perform that action at this time.
0 commit comments