简体   繁体   English

Azure WebJob QueueTrigger消息不会从队列中删除

[英]Azure WebJob QueueTrigger message is not deleted from queue

I have WebJob running continuously using the 1.0.0 WebJobs SDK. 我使用1.0.0 WebJobs SDK连续运行WebJob。
Here is configuration code. 这是配置代码。

public static void Main()
{
    var config = new JobHostConfiguration();
    config.Queues.MaxDequeueCount = 1;
    config.Queues.BatchSize = 1;

    var host = new JobHost(config);
    host.RunAndBlock();
}

Here is my job function signature. 这是我的工作职能签名。

public static void HuntVkusniyBlogRss([QueueTrigger("queue-rss")] string message,
    DateTimeOffset expirationTime,
    DateTimeOffset insertionTime,
    DateTimeOffset nextVisibleTime,
    string id,
    string popReceipt,
    int dequeueCount,
    string queueTrigger,
    CloudStorageAccount cloudStorageAccount,
    TextWriter log)
{
    ...
}

I expect that after running function successefully, message is deleted from triggering queue. 我希望在成功运行函数后,从触发队列中删除消息。 But I am getting function run more then once. 但我的功能运行时间超过一次。

Logging shows that it is run on every nextVisibleTime and dequeueCount is incrementing each time. 记录显示它在每个nextVisibleTime上运行,dequeueCount每次递增。

UPD: It looks like error happens after function is executed. UPD:看起来执行函数后会发生错误。 Here is logs from webjob dashboard: 这是来自webjob仪表板的日志:

[12/08/2014 13:10:47 > 51d5f4: INFO] Executing: 'Program.HuntVkusniyBlogRss' because New queue message detected on 'queue-rss'.
[12/08/2014 13:10:53 > 51d5f4: ERR ] 
[12/08/2014 13:10:53 > 51d5f4: ERR ] Unhandled Exception: Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (404) Not Found. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase`1 cmd, Exception ex)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.WindowsAzure.Storage.Blob.CloudBlobSharedImpl.<DeleteBlobImpl>b__1b(RESTCommand`1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    --- End of inner exception stack trace ---
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndDelete(IAsyncResult asyncResult)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass4.<CreateCallbackVoid>b__3(IAsyncResult ar)
[12/08/2014 13:10:53 > 51d5f4: ERR ] --- End of stack trace from previous location where exception was thrown ---
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.Azure.WebJobs.Host.Protocols.PersistentQueueWriter`1.<DeleteAsync>d__6.MoveNext()
[12/08/2014 13:10:53 > 51d5f4: ERR ] --- End of stack trace from previous location where exception was thrown ---
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.Azure.WebJobs.Host.Loggers.CompositeFunctionInstanceLogger.<DeleteLogFunctionStartedAsync>d__e.MoveNext()
[12/08/2014 13:10:53 > 51d5f4: ERR ] --- End of stack trace from previous location where exception was thrown ---
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<TryExecuteAsync>d__1.MoveNext()
[12/08/2014 13:10:53 > 51d5f4: ERR ] --- End of stack trace from previous location where exception was thrown ---
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.Azure.WebJobs.Host.Queues.Listeners.QueueTriggerExecutor.<ExecuteAsync>d__0.MoveNext()
[12/08/2014 13:10:53 > 51d5f4: ERR ] --- End of stack trace from previous location where exception was thrown ---
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.Azure.WebJobs.Host.Queues.Listeners.QueueListener.<ProcessMessageAsync>d__11.MoveNext()
[12/08/2014 13:10:53 > 51d5f4: ERR ] --- End of stack trace from previous location where exception was thrown ---
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at Microsoft.Azure.WebJobs.Host.Timers.BackgroundExceptionDispatcher.<>c__DisplayClass1.<Throw>b__0()
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
[12/08/2014 13:10:53 > 51d5f4: ERR ]    at System.Threading.ThreadHelper.ThreadStart()
[12/08/2014 12:08:18 > 51d5f4: SYS ERR ] Job failed due to exit code -532462766
[12/08/2014 12:08:18 > 51d5f4: SYS INFO] Process went down, waiting for 0 seconds
[12/08/2014 12:08:18 > 51d5f4: SYS INFO] Status changed to PendingRestart
[12/08/2014 12:08:23 > 51d5f4: SYS INFO] Run script 'HunterWebJob.exe' with script host - 'WindowsScriptHost'
[12/08/2014 12:08:23 > 51d5f4: SYS INFO] Status changed to Running
[12/08/2014 12:08:25 > 51d5f4: INFO] Found the following functions:
[12/08/2014 12:08:25 > 51d5f4: INFO] Cookagg.HunterWebJob.Program.HuntVkusniyBlogRss
[12/08/2014 12:08:25 > 51d5f4: INFO] Job host started

I ran into this problem because container are not always auto-created. 我遇到了这个问题,因为并不总是自动创建容器。 So, I created: 所以,我创建了:

azure-jobs-host-output 蔚蓝的作业主机输出
azure-webjobs-hosts 蔚webjobs的主机

I had the exact same problem, I had a separate storage account for the data and logs. 我有完全相同的问题,我有一个单独的数据和日志存储帐户。 If I used the same storage account for both this bug stops. 如果我使用相同的存储帐户这两个bug停止。

Check the webjobs SDK version, if that is lower than the 1.1.1.0, then ensure you are with latest version. 检查webjobs SDK版本,如果低于1.1.1.0,请确保您使用的是最新版本。

so it should be like below, we had the same issue with webjobs sdk version 1.0.1.0 and upgrading this to latest one fixed the issue. 所以它应该像下面一样,我们与webjobs sdk版本1.0.1.0有相同的问题,并将其升级到最新版本修复了该问题。

  1. Microsoft.Azure.WebJobs.dll (in our case current version was 1.0.1.0 and we need 1.1.1.0) Microsoft.Azure.WebJobs.dll(在我们的例子中,当前版本是1.0.1.0,我们需要1.1.1.0)
  2. Microsoft.WindowsAzure.Storage.dll (current version is 4.2.1.0, we need (≥ 4.3.0 && ≤ 5.0.2). Microsoft.WindowsAzure.Storage.dll(当前版本为4.2.1.0,我们需要(≥4.3.0&&≤5.0.2)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM