TransactionException op WCF two-way send port

On a 2-way WCF send port, I was getting an error for some of the calls it was requesting to the webservice. It turned out that the exception only occured for very large response files that had to be responded from the webservice.

To get the response file correctly, I already had to increase the TimeOut settings on the send port for the binding of the WCF-Custom adapter. But still I got an error with following message:

Message: SP_Dummy_WCF – System.Transactions.TransactionException: The operation is not valid for the state of the transaction.

at System.Transactions.TransactionState.EnlistVolatile(InternalTransaction tx, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)

at System.Transactions.Transaction.EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)

at Microsoft.BizTalk.Adapter.Wcf.Runtime.TxnBatch2..ctor(IBTTransportProxy transportProxy, ControlledTermination control, Transaction transaction, ManualResetEvent orderedEvent, Boolean makeSuccessCall)

at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkDeleteTxn.Execute(BizTalkExecutionContext executionContext)

So to rule out any timeouts coming from the adapter itself, I configured all the WCF TimeOuts to 1 hour.

WCFTimeOutSettings

Unfortunately, this didn’t help out a thing. So I kept looking for a correct solution.

Solution 1:

After some digging around, I found out the transaction max time out had to be increased. If this setting is not specified, it defaults to 10 minutes, and it cannot be overridden in code even. I ended up configuring this maximum transaction time out in the machine.config files of the server. Just add following in the machine.config file and restart all host instances to solve the issue:

<configuration>
<system.transactions>
<machineSettings maxTimeout=”00:59:00″ />
</system.transactions>
</configuration>

 
Note that this change will affect all transactions on this server.

Solution 2:

A second solution to this problem might be even more interesting, because the transaction setting will only be applied to this specific port. All credits go to Coen Dijkgraaf, check out his blog post here.

You can make sure that the port doesn’t use any transactions, by disabling it on the adapter configurations on the port.
Just open the port properties and click on the Configure button to change the WCF adapter settings. Open the Messages tab, and under Transactions you’ll see a checkbox to enable/disable transactions for this port.

Uncheck the checkbox to disable the use of transactions, and this would enough to solve the issue.

WCF-Transaction

Some info on this setting can be found at http://msdn.microsoft.com/en-us/library/bb226442.aspx.

Advertisements

3 comments on “TransactionException op WCF two-way send port

  1. cdijkgraaf says:

    I also hit this issue with large SAP responses. In my case I resolved it by not using Transactions (as I was just retrieving data). See my blog here http://cdijkgraaf.wordpress.com/2014/06/12/biztalk-server-negative-acknowledgement-issues-in-sap-and-wcf/

    • mitchke says:

      Thanks a lot for pointing it out.

      I ‘ve tried your solution and it also worked great for me.
      I’ve altered the post accordingly, adding your solution to it.

  2. pvandenheede says:

    Thank you for the blog, was really useful 😉

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s