Contents
|
Unit Of Work In NServiceBusWhen using a framework like NServiceBus there is usually a need to create your own unit of work in order to avoid having to repeat code over an over again in your message handlers.
In NServiceBus 2.6 your only hook into the message pipeline was the message modules, you can read about them in
Jonathan Oliver's post. In NServiceBus 3.0 there is a new way to do this, meet the IManageUnitsOfWork interface public interface IManageUnitsOfWork { /// <summary> /// Called before all message handlers and modules /// </summary> void Begin(); /// <summary> /// Called after all message handlers and modules /// </summary> void End(Exception ex = null); } The semantics are that that Begin() will be called when the transport messages enters the pipeline, remember that a transport message can consist of multiple application messages.
This allows you to do any setup that is required. Where you should go from here?The FullDuplex sample has an implementation of Unit Of Work, you can find it here. Please read the Unit Of Work implementation for RavenDB. This article was taken from Andreas Öhlund post that you can find here. |