pythonrabbitmqpikabrokerrmq

Get transferred file name in RabbitMQ using python pika


I'm using pika in Python3 to send CSV files from one node to another and everything is fine here. The only thing I need here is to get the transferred file name in the receiving node (e.g: filename-2017-01-01.csv)

Are there any ways to do this?

This is the processing part while getting the file.

def callback(ch, method, properties, body):
    ch.basic_ack(delivery_tag=method.delivery_tag)
    with open('test.csv', 'wb') as write_csv:
        write_csv.write(body)

Solution

  • Instead of storing the file name with the message, you can use this method to add a custom header with the file name.