NServiceBus icon indicating copy to clipboard operation
NServiceBus copied to clipboard

IMutateIncomingMessages not taken into account when handling messages

Open kamileon opened this issue 12 years ago • 7 comments

Hooked up a custom Mutator through IMutateIncomingMessages, which updates a property on the message (everything is fine so far). Now, when it gets to the handler, the old (not mutated) message is processed.

Incoming mutators work for us in v4.1.1 and broke after updating to v4.4.1 (not sure about the version in between).

The mutator returns a new instance of the message based on the original one.

kamileon avatar Feb 27 '14 17:02 kamileon

Hi @kami1eon

I have tried to reproduce this issue but was unable to.

Is it possible for you to send us a small reproduction?

johnsimons avatar Feb 27 '14 22:02 johnsimons

@kami1eon i tried to reproduce this problem but was unable to do so.

Here is my attempt https://github.com/Particular/BugsRepro/tree/master/1980IMutateIncomingMessagesIgnored

you can download it from here https://github.com/Particular/BugsRepro/archive/master.zip

Can you have a look at this solution and let me know if you are doing anything special that causes the problem to manifest

SimonCropp avatar Mar 13 '14 13:03 SimonCropp

@SimonCropp @johnsimons, managed to reproduce it in 4.4.2. If you create a new message in the mutator instead of populating the property as per @SimonCropp repro, the message doesn't get overwritten with the new reference. Now, this feels like a good behaviour as you SHOULD be mutating your messages, not issuing new ones. Doh!

Hope the above helps anyone who encounters this changed mutating "behaviour". I wouldn't classify this as bug, many thanks!

kamileon avatar Mar 21 '14 16:03 kamileon

I also relied on the feature of being able to substitute one message for another type in IMessageMutator which has now broken. Is this by design? (ie won't fix)

If so, is there a simple method of receiving one type and having NServiceBus process another message type (I use this for locally stored messages that come from a database which I 'SendLocal' and have them dispatched)

jfberry avatar Apr 10 '14 09:04 jfberry

You can create a pipeline behavior to do this. I'll try to create a gist on how to do it later today

andreasohlund avatar Apr 10 '14 10:04 andreasohlund

Andreas, that would be very much appreciated - was about to send a message to support

jfberry avatar Apr 10 '14 11:04 jfberry

Well most likely patch this but in the mean time this is how you can use a pipeline override to change the message type on the fly:

https://gist.github.com/andreasohlund/10401244

The gist is confirmed to work with NSB 4.4.2

Hope this helps!

/Andreas

On Thu, Apr 10, 2014 at 11:38 AM, jfberry [email protected] wrote:

I also relied on the feature of being able to substitute one message for another type in IMessageMutator which has now broken. Is this by design? (ie won't fix)

If so, is there a simple method of receiving one type and having NServiceBus process another message type (I use this for locally stored messages that come from a database which I 'SendLocal' and have them dispatched)

Reply to this email directly or view it on GitHubhttps://github.com/Particular/NServiceBus/issues/1980#issuecomment-40059691 .

andreasohlund avatar Apr 10 '14 16:04 andreasohlund