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

How to handle the Exception when RegisterEventProcessorAsync

$
0
0

In our Cloud Service project, we have 2 instances for work role (deploy to Azure), the work role is consume events from the EventHub using EventProcessorHost).

When we want to register EventProcessor to consume data (see below):

await eventProcessorHost.RegisterEventProcessorAsync<eventProcessor>();

Sometimes we will got the Exception:

Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (412) There iscurrently a lease on the blob and no lease ID was specified in the request.. ---> System.Net.WebException: The remote server returned an error: (412)There is currently a lease on the blob and no lease ID was specified in the request..

  at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase`1 cmd, Exception ex)

   at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpWebResponse resp, T retVal, StorageCommandBase`1 cmd, Exception ex)

   at Microsoft.WindowsAzure.Storage.Blob.CloudBlobSharedImpl.<DeleteBlobImpl>b__1b(RESTCommand`1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx)

   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult)

   --- End of inner exception stack trace ---

   at Microsoft.WindowsAzure.Storage.Core.Util.StorageAsyncResult`1.End()

   at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndDeleteIfExists(IAsyncResult asyncResult)

   at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass1`1.<CreateCallback>b__0(IAsyncResult ar)

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

   at Microsoft.ServiceBus.Messaging.BlobLeaseManager.<DeleteAllAsync>d__2a.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at Microsoft.ServiceBus.Messaging.EventProcessorHost.<InitializeAsync>d__4.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at Microsoft.ServiceBus.Messaging.EventProcessorHost.<StartAsync>d__e.MoveNext()

   --- End of inner exception stack trace ---

   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)

   at System.Threading.Tasks.Task.Wait()

at awaiteventProcessorHost.RegisterEventProcessorAsync<eventProcessor>();

If we got the Exception, we won’t got messages any more.

From the Call Stack, we found it was cause by delete the Blob. So we wonder that, when we callRegisterEventProcessorAsync,the hub will delete the blob and renew one in Storage?

If we delete the blob for the EventHub manually and then run our server again. It worked as usual.

But we can do it like this way manually, so is there any way to handle the exception in code to make the EventProcessorHost worked?

Thanks so much!


Viewing all articles
Browse latest Browse all 1916

Trending Articles