Transactional behavior in a receive location using an adapter
Quite a few customers developing custom adapters built on the WCF LOB Adapter SDK have come back to us asking for details on how to have transactional behavior while receiving messages from the LOB and submitting them to BizTalk (receive location) - for example, assume in your receive location:
- You read some data from the LOB
- You delete the data from the LOB (since you don't want to read it again)
- In IInboundHandler, you construct a message containing this data
- You return this message via the out parameter in the TryReceive function (in other words, you are submitting this message into BizTalk).
If an error occurs after step 4, you have lost the data! (since it has already been deleted from the LOB).
If your LOB supports transactions, then you can prevent this from happening - the same transaction can be used to read + delete the data from the LOB, as well as submit the message into BizTalk, and if anything fails at any point, everything is rolled back.
More information on how you can do this - read this post by Sonu Arora at http://blogs.msdn.com/sonuarora/archive/2007/06/19/transaction-support-in-inbound-message-exchange-handler.aspx.