Nservicebus: Using TTBR with MSMQ in transaction mode ReceiveOnly fails in V6

Created on 27 Sep 2016  路  5Comments  路  Source: Particular/NServiceBus

When using Time To Be Received (TTBR) with MSMQ and using transaction mode ReceiveOnly you get the following exception:

System.Exception: Failed to send message to address: PerformanceTest@ZOLDER. Sending messages with a custom TimeToBeReceived is not supported on transactional MSMQ.

Expected behavior

This applies to V5 when having transactions enabled as V5 MSMQ is equal to V6 AtomicReceiveWithSends. However, when using ReceiveOnly in V6 I would expect TTBR to work as none of the send messages should be participating in a (transport) transaction when using ReceiveOnly

Documentation

MSMQ will however only allow a single TimeToBeReceived for all messages in a transaction. It will silently copy the TimeToBeReceived from the first message enlisted to all other messages in the transaction, leading to a potential message loss scenario.

Source: https://docs.particular.net/nservicebus/messaging/discard-old-messages#caveats-msmq-transport

Bug

All 5 comments

be participating in a (transport) transaction when using ReceiveOnly

Correct, outgoing messages shouldn't participate, we have a bug raised for this MSMQ bug already #3562

Nice, didn't remember that one. Was just about to open an issue with a title

MSMQ TransactionMode.ReceiveOnly is actually
TransactionMode.SendsWithAtomicReceive

Should we add this as a work item to #3562 (something to verify while doing that work) and close this one?

Had a discussion with @tim and @danielmarbach and the current transaction behavior can be justified in the context of _batched sends_ even in the context of _ReceiveOnly_ but that transaction should not be the transaction of the receive operation.

@danielmarbach also suggested that it might be possible to use TTBR when using immediate dispatch

I verified this and this works. I'll update the doco with this workaround for TTBR.

With 6.1, TTBR is supported when using TransportTransactionMode.ReceiveOnly. For more details see the PR #4218.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timbussmann picture timbussmann  路  8Comments

janpieterz picture janpieterz  路  10Comments

andreasohlund picture andreasohlund  路  8Comments

tmasternak picture tmasternak  路  6Comments

timbussmann picture timbussmann  路  3Comments