开发者

WCF MSMQ service not retrying when using transactional

开发者 https://www.devze.com 2023-02-21 10:43 出处:网络
I have a wcf service that I am hosting within a windows service on a windows 2003 server that is listening on a MSMQ queue.I set the ReceiveRetryCount = 2 on the netmsmqbinding.The service was setup t

I have a wcf service that I am hosting within a windows service on a windows 2003 server that is listening on a MSMQ queue. I set the ReceiveRetryCount = 2 on the netmsmqbinding. The service was setup to use transactions ([OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete= true)]). The service was functioning great.

I needed to turnoff the transactions due to a database call that couldn't support MSDTC. So I switched the service properties to

[OperationBehavior(TransactionScopeRequired = false)]

Now, when an exception or fault is thrown, no retry occurs, the fault handler for the service never fires. The original message ends up in the system DLQ. I would like the fault h开发者_StackOverflowandler to handle the faults after two retries. Any ideas?


Switch things back to the way they were before.

Around the database call, add the following (code is done from memory- let me know if I need to fix this up a bit):

// using System.Transactions;

using( var ts = new TransactionScope( TransactionScopeOption.Suppress ) )
{
  // Call DB stuff
  ts.Complete();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号