NServiceBus Unit Of Work - get which handler is called?

237 Views Asked by At

I'm trying to write a Unit Of Work for NServiceBus that will be called before and after each message handler to measure the time it takes for that handler to run and write it in to a database.

I was able to successfully write the Unit Of Work, but at the Begin() method implementation, how can I tell which handler is being called?

2

There are 2 best solutions below

1
Sean Farmar On

You can use ServiceInsight to get this kind of information. See docs on ServiceControl and ServiceInsight for more info. another channel may be NServiceBus.Performance Counters.

0
Chris Bednarski On

I'd look into the decorator pattern and deal with this by dependency injection

example https://code.google.com/p/autofac/wiki/AdaptersAndDecorators

You could create a decorator for the IHandleMessages interface and configure all message handlers to return a proxy to the real message handler which adds the required instrumentation logic.