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

RetryLater fail to send message #400

Open
waldo2188 opened this issue Jul 17, 2019 · 2 comments
Open

RetryLater fail to send message #400

waldo2188 opened this issue Jul 17, 2019 · 2 comments

Comments

@waldo2188
Copy link

First, thank you for this library, it helps a lot !

RabbitMq : 3.7.16
RawRabbit : 2.0.0-rc5

I have two apps, one who send a message on the bus Sender and one who listen Listner.
The Listner app is a console application. I’ve followed the sample you provide.

I’ve setup SubscribeAsync like describe here #356 (comment)

I have no issue to emit a message and read it, but the retry later leads to an error in RabbitMQ:
Error in the RabbitMQ logs :

2019-07-17 11:26:01.290 [error] <0.869.0> Channel error on connection <0.739.0> (172.27.0.2:36527 -> 172.27.0.3:5672, vhost: 'emailing', user: 'Listner'), channel 3: operation basic.publish caused a channel exception precondition_failed: user_id property set to 'Sender' but authenticated user was 'Listner'

Debug logs of the Listner app :

[09:09:06 DBG] Stage HandlerInvoked has no additional middlewares registered.
[09:09:06 INF] Declaring exchange default_retry_later_exchange.
[09:09:06 DBG] Done processing topology work.
[09:09:06 INF] Message is marked for Retry. Will be published on exchange e-emailing with routing key email_low_priority in 00:00:02
[09:09:06 INF] Declaring queue retry_for_e-emailing_in_2000_ms.
[09:09:06 DBG] Done processing topology work.
[09:09:06 INF] Binding queue retry_for_e-emailing_in_2000_ms to exchange default_retry_later_exchange with routing key email_low_priority
[09:09:06 DBG] Done processing topology work.
[09:09:06 DBG] Existing connection is open and will be used.
[09:09:06 INF] Unbinding queue retry_for_e-emailing_in_2000_ms from exchange default_retry_later_exchange with routing key email_low_priority
[09:09:06 DBG] Done processing topology work.
[09:09:06 DBG] Stage MessageAcknowledged has no additional middlewares registered.

To try to understand what’s wrong I set up a Dummy project to play https://github.com/waldo2188/RawRabbitPlayground.

With a TCPDUMP I discover that when the “retry later” request is sent to RabbitMQ by the Listner app, in the header of the request the User-Id is Sender. That’s the user id of the Sender app, not the one of the Listner app. And I think that’s why RabbitMQ raise an error.

What am I doing wrong?

@waldo2188
Copy link
Author

I continue to dig and maybe find something.

In the class RawRabbit.Common.RetryInformationHeaderUpdater, you manage the update of the message header.

For test purpose, I change the value of the property args.BasicProperties.UserId with the value : "Listner"

And It’s works !

I don’t know if it’s a feature or a bug, but, how to define the `UserId' of the real user who should send the message?

@edallenjr
Copy link

The reason RabbitMQ rejects the publish to the retry exchange (as well as the default error exchange) is that in order to preserve all of the message properties as they were originally published the relevant middleware simply reuses almost all of the BasicProperties in the incoming message, including the UserId.

This is fine if the publisher and consumer are using the same RabbitMQ user id, however if they are different RabbitMQ will not allow the consumer to publish a message using the original publisher's user id. I have what I believe is a fix for it and will be creating a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants