views:

227

answers:

1

I am using transactions across WCF client and services with netTcp binding. I have enabled DTC and transactions are flowing as expected.

I want to test the transactions to timeout.

The Client initiates transaction as

using (TransactionScope scope = 
    new TransactionScope(TransactionScopeOption.Required,new TimeSpan(0,0,1,0)))
    {
     ...

On the Service, I have enabled transaction behavior for timeout

<behavior name="Services.Behavior.NetTcp">
          <serviceTimeouts transactionTimeout="00:00:01"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>

and the Service end point,

<service behaviorConfiguration="Services.Behavior.NetTcp"
    name="Services.Accounts.AccountsService">
    <endpoint binding="netTcpBinding" bindingConfiguration="TranNetTcpBinding"
      contract="Services.Accounts.Interfaces.IAccountsService" />
    <endpoint address="mex" binding="mexTcpBinding" name="MexTcp" contract="Services.Accounts.Interfaces.IAccountsService" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:2222/Accounts"/>
      </baseAddresses>
    </host>
  </service>

and using default the default transaction scope on service too

using (TransactionScope ts = new TransactionScope())
{

But I don't get transactions timing out from the Service. If I reduce the client timeout from 1 minute, I can see the transactions being timed out.

I know that if I use Transaction Options on the Service, it would not read the timeout values from the config file, here I am not using any of these options.

Any idea why transactions are not timing out from the Service even when the transactionTimeout is 1 Second, which is not sufficient time in my case to complete the operation.

And how do I check the timeout value set on the Service at runtime?

Update 1:
From Jual Lowy in Programming WCF Services book:
When a transaction flows into a service that is configured with a shorter timeout than the incoming transaction, the transaction adopts the service's timeout, and the service gets to enforce the shorter timeout. When a transaction flows into a service that is configured with a longer timeout than the incoming transaction, the service configuration has no effect.

From Lerox Bustamante: From the webcast Mentions that the Service timeout has no effect if it joins an existing transaction, quite the opposite of what Jual is saying.

Update 2:
From tests I can confirm that Bustamante is correct. If I apply the following attribute on method signature in Service interface,

[TransactionFlow(TransactionFlowOption.NotAllowed)]

which doesn't allow client transaction to flow, and create a new transaction due to the usage of attribute at the Service implementation,

[OperationBehavior(TransactionScopeRequired = true)]

gets the specified timeout period from Service config file and times out correctly.

Thanks

A: 

Have you tried setting the timeouts on the client?

For example:

<binding name="IncreasedTimeout" closeTimeout="12:00:00" openTimeout="12:00:00"
             receiveTimeout="12:00:00" sendTimeout="12:00:00">
JL
This will increase the operation time and not related to transactions.
skjagini