WCF LOB SDK and transactions (2 phase commit) RRS feed

  • Question

  • Using WCF LOB SDK SP1 (  with BizTalk 2006 R2
    Within my adapter's class that implements Microsoft.ServiceModel.Channels.Common.IInboundHandler, within
    StartListener I have a delegate (based on System.Timers.Timer) that calls a stored procedure and then
    uses System.ServiceModel.Channels.Message.CreateMessage() to create a message.
    Then is uses the technique as described in the EchoAdapter tutorial to enqueue that message onto

    Is there any assurance that BizTalk has committed the msg into its MessageBox ?

    If we want our LOB system to be involved in this distributed unit of work (2 phase commit transaction)
    how can we tell if the msg has been committed by BizTalk 2006 R2 ?

    How to use LOB adapter/custom code/BizTalk API to enable two phase commit/distributed unit
    of work (Between Oracle and BizTalk Sql Message box)
    How to use LOB adapter/custom code/BizTalk API to control unit of work with Message Box and another
    external sql server database

    Thursday, February 28, 2008 8:22 PM

All replies

  • (a) In TryReceive, start a transaction yourself and set that transaction on the message you return. BizTalk will then use that same 2PC transaction to persist the message in the message box.
    (b) To set the transaction on the message, use "TransactionMessageProperty.Set(transaction, message)".
    (c) In the Reply function within IInboundReply, that is when you should commit your transaction.
    Wednesday, March 12, 2008 5:18 PM

    (a) How do I start a transaction within IInboundHandler's TryReceive() ?


    I found this forum entry which seems somewhat related:

    but what do I do if that:

    bool tmp = OperationContext.Current.IncomingMessageProperties.ContainsKey("TransactionMessageProperty");

    returns true?


    Can you provide modified EchoAdapterInboundHandler.cs that demonstrates?


    (b) So in EchoAdapter's TryReceive() the logic would be something like:


    if (inboundQueue.Count != 0)


    message = inboundQueue.Dequeue();

    if (message != null)


    TransactionMessageProperty.Set(tx, message); // how do I get this tx ??

    return true;




    Right ?


    (c) You mean within the class that implements:




    An updated EchoAdapterInboundHandler.cs showing this tx support would be very helpful.


    One more question:  Do I need to, in my adapter's constructor(s) put:

    Settings.Messaging.SupportsTransactedInbound = true;



    Please help.  I am getting urged to put some code into the adapter that will put a unique msgid into a SQLServer db, and retrieve it on every call ... doesn't feel right.

    Thursday, March 13, 2008 3:45 PM
  • You can start a transaction by:

    CommittableTransaction ct = new CommittableTransaction();

    You can then use this within a TransactionScope:

    using (TransactionScope ts = new TransactionScope(ct))
    //do work

    Finally, commit your transaction:


    If you are starting your own transaction, (as above) and setting it on your message, you need to have:
    Settings.Messaging.SupportsTransactedInbound = false;
    Thursday, March 20, 2008 1:02 AM