rebus-org / Rebus.Async

:bus: Experimental async extensions for Rebus
https://mookid.dk/category/rebus
Other
13 stars 9 forks source link

Unable to assign custom message id #16

Closed nativenolde closed 3 years ago

nativenolde commented 3 years ago

Hello @mookid8000,

because my messages already having unique ids, i want to use them also for rebus, to have a consistent logging through the whole request, including rebus. Thats not a problem for fire-and-forget commands using Send, as you can see here:

AssignDefaultHeadersStep (L56-L59

if (!headers.ContainsKey(Headers.MessageId))
{
    headers[Headers.MessageId] = Guid.NewGuid().ToString();
}

Unlike Send, Request and Reply does not support that, as it seems to force the message to have a special prefix, as you can see here:

AsyncBusExtensions (L77-L82)

var messageId = $"{ReplyHandlerStep.SpecialMessageIdPrefix}_{Guid.NewGuid()}";

var headers = new Dictionary<string, string>
{
    {Headers.MessageId, messageId},
};

Would it be possible to pick up an incoming message id as a whole? Or has it to be specially prefixed and only the "random/guid-part" could be picked up?

Sincerely, nolde

mookid8000 commented 3 years ago

I'm not sure I understand the question.... 😐 but I'm pretty sure the special message ID prefix is there for a reason, so I would not expect it to be readily possible to provide a custom ID from the outside in this case.

nativenolde commented 3 years ago

it was my assumption too, that the special prefix is being used for a good reason. therefore i would like to replace just the random (guid) part, instead of the whole message id...

My suggestion would be: https://github.com/rebus-org/Rebus.Async/pull/17

nativenolde commented 3 years ago

What's your thoughts on that?

mookid8000 commented 3 years ago

That's a nice way to fix it 🙂

mookid8000 commented 3 years ago

Your fix is out in Rebus.Async 7.2.0 🙂

nativenolde commented 3 years ago

Thank you