-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Add HeaderStamp to add custom headers #34481
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
Conversation
f38b636
to
f70e466
Compare
@alanpoulain thanks for this contribution and for explaining it in the description of your PR. To allow us better evaluate this (and document it, if merged) could you please add a simple example of this feature in action? Thanks. |
f70e466
to
39bd4e3
Compare
@javiereguiluz sorry for the delay! Rebased and example added in the description of this PR. |
Any input about this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also deserialize the header stamp, right?
How do we handle message requeue? Should stamps be removed and re-added by a potential second transport?
I know I been speaking with @weaverryan about this. I was in favour of introducing a generic stamp, but Im not sure if Ryan chose to not do it because of a reason or just because there were not obvious use case for it at the time.
Is there an issue with the (de)serialization of this stamp? It seems to me there would be no issue. |
Will the stamp be present when I get the message back from the queue? ———— If I put a message on transport A. It uses some headers Foo. Then I consume the message, it fails and goes to the failure transport B. Will it still have the same headers Foo? Should it have the same headers or should headers be cleared? Could you please elaborate how it will work? |
For the second question, currently since the stamp is kept (and serialized), the headers will be kept too. If we use the I don't see why the headers should be cleared, but if there are some use cases maybe we could introduce another stamp (like a Also I see I've not modified the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary. Adding custom headers to AMQP is already possible by using the AmqpStamp AmqpStamp::createWithAttributes(['headers' => [ ... ])
. For other transports, adding custom headers is possible by decorating the serializer and returning the custom headers there.
Your solution will duplicate the headers both as serialized data and as headers in the transport.
I didn't see the possibility of using the For the other transports, if the stamp implements Feel free to close this PR if this use case is not needed. |
@Tobion with current implementation of amqp sender overriding already existing header entries (like |
I guess @alanpoulain, Im happy to close this if |
Add a
HeaderStamp
to add custom headers to an encoded message to be used by the transport.It's a proposal, maybe there is a better way to do this.
This feature would be useful in my case where I need to add a custom header to deduplicate the messages in an AMQP context. This is the RabbitMQ plugin I would like to use: https://github.com/noxdafox/rabbitmq-message-deduplication.
An example of how to use it: