Marco
Marco

Reputation: 2473

NServiceBus 5 without DTC involvement?

I am reading through the documentation and the following confuses me because it states at the top of the document with version 5 we get reliability without using the DTC.

These feature has been implemented using both the Outbox pattern and the Deduplication pattern. As a message is dequeued we check to see if we have previously processed it. If so, we then deliver any messages in the outbox for that message but do not invoke message-processing logic again. If the message wasn't previously processed, then we invoke the regular handler logic, storing all outgoing message in a durable storage in the same transaction as the users own database changes. Finally we send out all outgoing messages and update the deduplication storage.

I'm sure it's probably due to my lack of understanding, but wouldn't the fact that NServiceBus is opening it's own connection and transaction separate from the message handler (ex; calling repository for saving) database connection the transaction would be escalated to a full 2PC using the DTC?

Here is the documentation:

http://docs.particular.net/nservicebus/outbox/

Thanks!

Upvotes: 1

Views: 716

Answers (1)

janovesk
janovesk

Reputation: 1138

Yes, it would. Which is why it shares them with you instead.

NServiceBus expose these to you in the message handlers so you can reuse them and avoid the escalation.

Simply take a dependency on NHibernateStorageContext in your message handler constructor and it gives you access to the correct NHibernate.ISession and NHibernate.ITransaction.

Upvotes: 1

Related Questions