define indigo transaction for netMsmqBinding

How is possible to define using of wcf transaction with netMsmqBinding Does TransactionFlow exist

thanks,

Bojan



Answer this question

define indigo transaction for netMsmqBinding

  • Midget01

    Hello,

    I'm not sure if suggestion of using transaction flow with the net.msmq transport is right.

    In fact, net.msmq transport doesn't support flowing transactions for a simple reason - the client and server are fundamentally isolated in the queued scenarios. When the net.msmq client sends a message it doesn't know (and doesn't care) if the server is online at all. It is very possible that the server will pick up the message after a while (minutes, hours, days...). The default time-to-live setting on the net.msmq binding is 24 hours so you can imagine what latency we expect of the applications. The transaction timeout is typically much shorter than that - that's the reason why "flowing" transaction from the client to server doesn't make sense for a typical queued scenario.

    Now, how net.msmq transport uses transactions then The answer is that send operation and receive operation can participate in transaction. That is, if the transaction is aborted, the message is not actually sent (on the sender) and remains in the queue (on the receiver). The typicall usage is, for example, when I want to update the database in response to the message. If the database update fails, the transaction is aborted and the message remains in the queue so it can be read again. It is very importan to understand that transactions on the sender and receiver are separate and unrelated at all.

    In order to make such scenarios work, make sure that your net.msmq binding has ExactlyOnce set to true. On the sender, one can use call the proxy methods within the TransactionScope - the transport will pick up the transaction and use it for the send operation. On the receiver, mark your operation with [OperationBehavior(TransactionScopeRequired=true, TransactionAutoComplete=true)]. Your operation can access the receive transaction from Transaction.Current. Throwing an exception in the operation will cause the transaction to abort and hence the message will remain in the queue.

    thanks, - leszek


  • ShadowWolf

    netMsmqBinding is not exposing transactionflow setting, if we want, we can create custom binding with MSMQ transport and we can add transactionflow setting to custom binding.

    from SDK samples, I think, If client initiates the transaction,MSMQ binding also participating in transaction(May be MSMQ acting like RM,so in this case, we are running simple transaction between client and MSMQ,transactionflow may be more useful, if we want transaction between wcf client and wcf service)

    Please check this sample

    http://windowssdk.msdn.microsoft.com/library/default.asp url=/library/en-us/WCF_samples/html/71f5cb8d-f1df-4e1e-b8a2-98e734a75c37.asp

     

    -Thank you

    Madhu

     



  • define indigo transaction for netMsmqBinding