WCF & MSMQ & TransactionScope long process
Asked Answered
O

1

7

I am trying to develop a WCF service that take care of hundreds downloads and conversion together. I have been initialized MSMQ with a transaction queue that receive messages from an ASP.NET web application.

My question after a long research on Internet is how to manage the long process in the WCF service method that manage the MSMQ message.

The problem is that on download with small size, the process finish soon and the scope return complete to the MSMQ service, but if the download size is big and need 3/4 minutes to be downloaded, than the scope return still complete, but the MSMQ service resend the MSG to the WCF service and I have duplicated downloads.

I guess this is a problem of timeout, but I have already tried to config better my Host app.config without success.

      <netMsmqBinding>
    <binding name="OrderServiceMsmqBinding" 
             maxRetryCycles="1"
             receiveRetryCount="1"
             retryCycleDelay="00:05:20"
             deadLetterQueue="System"
             receiveErrorHandling="Move"
             exactlyOnce="true"
             durable="true"
             receiveTimeout="00:10:00"
             sendTimeout="00:20:00"
             timeToLive="1.00:00:00" useMsmqTracing="true">
      <security mode="None"></security>
    </binding>
  </netMsmqBinding>

and this is the method into WCF service:

   <OperationBehavior(TransactionScopeRequired:=True, TransactionAutoComplete:=True)> _
Public Sub FfmpegConversion(ffmpegjob As FfmpegJob) Implements IOrderService.FfmpegConversion
    Using sc As New TransactionScope(TransactionScopeOption.Required)
        Try
          ExecuteLongProcess()
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            sc.Complete()
        End Try
    End Using
End Sub

UPDATE

After long trials and research, I'm starting to think that is impossible to make long process into the method that is fired by the MSMQ queeue.

I workaround it using a different thread that manage the data, but now the problem is that I lose the TransactionScope vantage because once the job pass to the new thread, then the MSMQ delete the msg as believe that has been done.

Originally answered 22/7, 2012 at 13:54 Comment(1)
Have you tried making receiveRetryCount = 0?Sold
C
0

What is happening here is that the transaction gets timed out. You can specify a new value on machine.config file, and that's how you get long transactions...

http://blogs.inkeysolutions.com/2012/01/managing-timeouts-while-using.html

Cladding answered 3/9, 2013 at 14:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.