Cannot enlist the Transaction

On an initial load of 60000+ files our nServiceBus handler threw an exception

NServiceBus.Unicast.Queuing.FailedToSendMessageException: Failed to send message to address: queue@machine —> System.Messaging.MessageQueueException: Cannot enlist the transaction.


No repro – no issue. Sleeping for 61 seconds caused the same exception. Complete solution for download at the end of the post.

public void Handle(DoSomethingCommand message)
    // wait for the timeout of 1 minute
    // throws System.Messaging.MessageQueueException:
    Bus.Send<DoAnotherThingCommand>(m => { });


Looks like a transaction timeout. This is what the MSDTC Transaction Statistics look like
Every transaction is aborted.


Setting the transaction timeout for MSDTC did not solve this issue. The timeout of 0 (never timeout) still gave the exception. But thanks to Teun we’ve solved it.

Overwriting the transaction timeout in the config did the trick.

  <defaultSettings timeout="00:05:00"/>

Now the transactions succeed and the DoAnotherThingCommands are send and processed.


About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , . Bookmark the permalink.

4 Responses to Cannot enlist the Transaction

  1. Pingback: DTC troubles with long running transactions in NServiceBus

  2. bjolicoeur says:

    Thanks for posting! This saved me a bunch of time.

  3. Trygve Lorentzen says:

    Alternative solution (better?): Create a new TransactionScope with TransactionScope.Suppress as long as all files are loaded before the Bus.Send. See

    This way you can remove transaction scope on individual handlers or part of handlers. Downloading a large file from the internet, then Bus.Send(HandleDownloadedFileCommand) is an example usage.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.