0

so I'm working on a Project using RabbitMq and Python 3.7. I first used Pika but then I switched to rabbitpy since it's Thread safe and we are using Multithreading in the Project. I looked at the Documentation of rabbitpy and I really like the API, so last Time I added the Mandatory publishing Feature to the Project but something interesting has happened.

when I Make a Subscription and then publish a msg, things works perfectly. that means if the Consumer Queue was already declared before publishing then it works great but if I tried to publish before making Subscription rabbitpy throw this Exception: NO_ROUTE(312)

before I added the Mandatory=True argument all was working fine for me. So I don't understand what is happening under the Hood and to be honest the rabbitpy Docs is not the best and not many People are using it in their Project that's why there is not many Example on it in the internet. that's why I hope someone already had this and fixed it somehow. I know that I can easily remove the Mandatory argument and then all will work good but I liked the Idea of the Mandatory Publishing since it will indicate whether Rabbitmq has received the published msg or not and so I can monitor my messages through it. Now that's what I understand from the docs but as I mentionned the Docs of rabbitpy are not very well explained (at least to me) so if someone have some Opinion or understanding of the Mandatory Publishing and also the Immediate argument It will make my Day better to hear any Explanation. here is a link of the Docs where it is mentionned rabbitpy_mandatory . The Code Example I'm using is basically the same as the Code in the Docs that's why I will not add some Code and confuse things.

PS: another Information that may help debugging the Problem is that I'm using Multithreading. So I'm making a rabbitpy Connection object in the Main and then I'm assigning a independant Channel to every Thread. so the Threads share the Connection but not the Channels. that should be No Problem since it worked for me already before using the Mandatory publishing but I'm adding it only as an Information, maybe it will help at the end

basilisk
  • 1,156
  • 1
  • 14
  • 34

1 Answers1

1

Essentially in this care Rabbitpy is wrapping under the hood basic.nack which is a negative acknowledgement from the Broker that it had not valid routes to route the message further and hence it is not no longer responsible for the message. The publisher is hence forth responsible for taking appropriate call to either re-publish the message or take any other action as desirable.

When the Mandatory flag is set to False , the broker does not responds back to the publisher if a message is further routed to an exchange or not.

You should read the Publisher Confirms documentation from RabbitMQ for better understanding. Publisher Confirms

Soumen Mukherjee
  • 2,953
  • 3
  • 22
  • 34
  • I already read that Doc, but I didnt figure out what is happening. Ok so Rabbitmq receive the msg but doesnt know what to do with it since the Exchange is not declared yet and that's why there is Exception? or because the msg was already in the Exchange but the Consumer Queue was not declared yet and so the Exchange didn't know where to publish the msg and that's why it sent it back to the publisher ? and if it a case from those two cases which one is it ? and how can I prevent this from happening? – basilisk Aug 20 '19 at 19:24
  • at the Time I used it, I though actually that this Feature will indicate if there is a Problem with Rabbitmq itself and that Rabbitmq cannot accept the msg from the publisher because of some Problem with rabbitmq or server or that rabbitmq is down for that Moment. but I think It's not like that – basilisk Aug 20 '19 at 19:25