npv2k1 commited on
Commit
92ff6e6
·
1 Parent(s): ddca844

fix: update message logging format and rename publish function for clarity

Browse files
src/modules/transporter/rabbitmq.py CHANGED
@@ -37,7 +37,7 @@ def queue_listener(queue_name, host="localhost"):
37
 
38
  @queue_listener("hello-python")
39
  def process_message(msg):
40
- print(f"[x] Received: {msg}")
41
 
42
 
43
  @queue_listener("test")
@@ -47,7 +47,7 @@ def test_queue_listener(msg):
47
 
48
 
49
  # publish a message to the queue
50
- def publish_message(queue_name, message):
51
  connection = pika.BlockingConnection(parameters)
52
  channel = connection.channel()
53
  # channel.queue_declare(queue=queue_name, durable=True)
@@ -61,4 +61,4 @@ def publish_message(queue_name, message):
61
  )
62
  print(f"[x] Sent: {message}")
63
 
64
- publish_message("hello-python", "RabbitMQ is running!")
 
37
 
38
  @queue_listener("hello-python")
39
  def process_message(msg):
40
+ print(f"[rabbitmq][hello-python] Received: {msg}")
41
 
42
 
43
  @queue_listener("test")
 
47
 
48
 
49
  # publish a message to the queue
50
+ def add_to_queue(queue_name, message):
51
  connection = pika.BlockingConnection(parameters)
52
  channel = connection.channel()
53
  # channel.queue_declare(queue=queue_name, durable=True)
 
61
  )
62
  print(f"[x] Sent: {message}")
63
 
64
+ add_to_queue("hello-python", "RabbitMQ is running!")