Thread Principal for Consumers

71 views
Skip to first unread message

Quooston

unread,
May 8, 2013, 3:35:48 AM5/8/13
to masstrans...@googlegroups.com
Hello,

I'd like to set set the thread principal at the consumer end to say, to the principal related to the formsidentity for a logged in user. The reason is that I'd like to know who was responsible for sending the message at the consumer. The requirement here is specifically for an audit trail where the event I raise as a result of a command being successfully processed needs to record who/what/when etc, and I'd prefer not to clog messages full of this stuff.

I've tried an Inbound Message Interceptor but by then its obviously too late, unless I'm missing something. 

Any help appreciated,
Q

Patrick Doran

unread,
May 8, 2013, 4:49:22 PM5/8/13
to masstrans...@googlegroups.com
What exactly do you mean clog your messages? The implementation or the actual message that is transmitted via your transport?

Why not have your messages that need to be audit-able implement IAuditable or something that automatically populates the users identity to a property (not sure if user principal is serializable) in your message and then on the consumer side you have the data you need. This seems the most straight forward to me.

Quooston

unread,
May 8, 2013, 7:44:38 PM5/8/13
to masstrans...@googlegroups.com
Thanks for the reply Patrick.

Your definition of clog is correct. If I am going to need to know the "who" a whole lot of the time, it would be nice for the native construct of IPrincipal to be available to me for that.

I have actually done something quite similar to what you suggested.

Chris Patterson

unread,
May 8, 2013, 10:42:42 PM5/8/13
to masstrans...@googlegroups.com
The best way to intercept a consumer is by writing your own consumer factory to set/remove for the message handler in the consumer. You can delegate to the default implementation, just intercept and wrap the Action<message> with your code to set/remove the pricipal.



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/Hb8E90IQYYwJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joshua Chan

unread,
May 16, 2015, 12:52:21 AM5/16/15
to masstrans...@googlegroups.com
Is there an example of this factory? I just ran into the same thing.
Reply all
Reply to author
Forward
0 new messages