i have Queue that has 3 consumers each consumer should consume type of message based on binding keys(which are 3 and all of them binded the that queue) i want to decide which consumer consume the recieved message each time a message reaches a queue
I know that i should be doing each consumer has its own queue but this is case is very specific and i must link them in the same queue
def consume_messages(exchange_name, queue_name, binding_key_1, binding_key_2,channel):
try:
channel = channel
def callback(ch, method, properties, body):
print(f" [x] Received {body}")
channel.basic_consume(queue=queue_name, on_message_callback=callback, auto_ack=True)
print(f" [*] Waiting for messages on binding keys: {binding_key_1}, {binding_key_2}. To exit press CTRL+C")
channel.start_consuming()
except Exception as e:
print(f"Error while consuming messages: {str(e)}")
I thought i can change the callback message to do somthing but i don’t think it would work , cuz if the callback will be invoked means that the message already consumed
If you have any solution please help
Thank you very much