Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification about mandatory Flag in Produce Class #1039

Closed
Gsantomaggio opened this issue Apr 9, 2019 · 3 comments
Closed

Clarification about mandatory Flag in Produce Class #1039

Gsantomaggio opened this issue Apr 9, 2019 · 3 comments

Comments

@Gsantomaggio
Copy link
Contributor

@Gsantomaggio Gsantomaggio commented Apr 9, 2019

Hi,
Why the mandatory flag is marked as not_supported on the documentation and inside the code?

I tried it and seems to work correctly:

env:

pip freeze
amqp==2.4.2
kombu==4.5.0
PyAMQP==0.0.7.1
...

code:

from __future__ import absolute_import, unicode_literals

from kombu import Connection, Producer


def on_return(exception, _exchange, routing_key, _message):
    print("Exception: %s, routing_key: %s" % (exception, routing_key))


with Connection('amqp://guest:guest@localhost:5672//') as connection:
    producer = Producer(connection, on_return=on_return)
    producer.publish({'hello': 'mandatory'}, mandatory=True,
                     routing_key='queue_does_not_exist')

result:

Exception: Basic.return: (312) NO_ROUTE, routing_key: queue_does_not_exist

312 NO_ROUTE is exactly the AMQP error code

Thank you

@auvipy
Copy link
Member

@auvipy auvipy commented Apr 15, 2019

PR is welcome

@Gsantomaggio
Copy link
Contributor Author

@Gsantomaggio Gsantomaggio commented Apr 15, 2019

@auvipy thank you,
I am asking why the mandatory flag is considered not_supported.
I will be glag to make a PR to remove the info on the documentation, but I'd like to know your opinion on it.

@matteius
Copy link
Contributor

@matteius matteius commented Aug 23, 2019

@Gsantomaggio the answer is because mandatory flag was added in 2010 by @ask and added to the docstrings as not supported and passed along all the way into the transports basic_publish kwargs and then never used within kombu, but the kwargs are sometimes passed for example in the virtual base transport it passed it to self._put which seems to ignore it, but perhaps some transport has been implemented that could use a mandatory flag? I am not sure the intention but it kind of feels like something that isn't mandatory and could be removed from the code base if you ask me.

# anon exchange: routing_key is the destination queue
return self._put(routing_key, message, **kwargs)
@auvipy auvipy closed this May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.