Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Azure Service Bus WorkerRole not executing async Method

$
0
0

I have hosted Service Bus project on Azure and woker role is processing all messages. I have noticed that “asyncTaskWait() not executing always. sometime it is executing there is no guarantee it will work.

I am sure there is no exception and placed the logs before and after it is logging the details but not executing theasyncmethod.

sample code :

CreateInstance methodnot executing (inconsistent behavior)

MyTestClass is not creating instance (inconsistent behavior).

publicoverridevoid Run()

        {

           Trace.WriteLine("Starting processing of messages");

           OnMessageOptions options =newOnMessageOptions();

            options.AutoComplete =true;

            options.AutoRenewTimeout =TimeSpan.FromMinutes(1);

           // Initiates the message pump and callback is invoked for each message that is received, calling close on the client will stop the pump.

            Client.OnMessage((receivedMessage) =>

            {

               try

                {

                           Task.Factory.StartNew(() => longProcess(receivedMessage,ref Processcount, dictionary));

                }

               catch (Exception ex)

                {

                    logData("Run Expcetion:"+ ex.ToString());

                   // Handle any message processing specific exceptions here

                }

            });

           

        }

 publicvoid longProcess(BrokeredMessage receivedMessage, refint Processcount,Dictionary<string,string> dictionary)

        {

           try

            {

                CreateInstance(dictionary).Wait();

            }

           catch (Exception ex)

            {

                logData("Run Expcetion:"+ ex.ToString());

               // Handle exception here.

               // Log, write to poison message queue etc ...

            }

           finally

            {

            }

        }

       publicstaticasyncTask CreateInstance(Dictionary<string,string> dictionary)

        {

            logData("CreateInstanceThreadState:"+ Thread.CurrentThread.ThreadState.ToString());

            logData("CreateInstanceThreadId:"+ Thread.CurrentThread.ManagedThreadId.ToString());

            logData("CreateInstanceThreadIsBackGround:"+ Thread.CurrentThread.IsBackground.ToString());

           Console.WriteLine("CreateInstance");

           MyTestClass obj =newMyTestClass();

        }

Please help me.




Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>