我正在使用 Microsoft.Azure.WebJobsMicrosoft.Azure.WebJobs.ServiceBus包来捕获ServiceBus主题事件。

功能代码如下-

public class Functions
{
    [Singleton]
    public static void Event4Processor(
      [ServiceBusTrigger("MyTopic", "MySubscription", AccessRights.Listen)] BrokeredMessage message,
      TextWriter log)
    {
        log.WriteLine(message);
    }
}

但是,我收到此错误
{
  "Type": "FunctionCompleted",
  "EndTime": "2015-09-28T13:53:36.6540039+00:00",
  "Failure": {
    "ExceptionType": "System.ArgumentNullException",
    "ExceptionDetails": "System.ArgumentNullException: Value cannot be null.\r\nParameter name: bindingData\r\n   at Microsoft.Azure.WebJobs.Host.Bindings.BindingDataPathHelper.ConvertParameters(IReadOnlyDictionary`2 bindingData)\r\n   at Microsoft.Azure.WebJobs.Host.SingletonManager.GetBoundScope(String scope, IReadOnlyDictionary`2 bindingData)\r\n   at Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding`1.<BindCoreAsync>d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding`1.<BindAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLogMessageAsync>d__c.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<TryExecuteAsync>d__1.MoveNext()"
  },
  "ParameterLogs": {},
  "FunctionInstanceId": "a1dcf0a9-113f-4c7e-b136-fb8d8b7ee4aa",
  "Function": {
    "Id": "WebJobServiceBus.Functions.Event4Processor",
    "FullName": "WebJobServiceBus.Functions.Event4Processor",
    "ShortName": "Functions.Event4Processor",
    "Parameters": [
      {
        "NamespaceName": "my-ns",
        "TopicName": "myevents",
        "SubscriptionName": "mysubscription",
        "Name": "message",
        "DisplayHints": {
          "Description": "dequeue from 'mytopic/Subscriptions/mysubscription'",
          "Prompt": "Enter the queue message body"
        }
      },
      {
        "Type": "ParameterDescriptor",
        "Name": "log"
      }
    ]
  },
  "Reason": "AutomaticTrigger",
  "ReasonDetails": "New ServiceBus message detected on 'MyTopic/Subscriptions/MySubscription'.",
  "StartTime": "2015-09-28T13:53:35.6639049+00:00",
  "HostInstanceId": "ad1f5b26-ddec-4326-9cfb-df585065e773",
  "HostDisplayName": "WebJobServiceBus",
  "SharedQueueName": "azure-webjobs-host-ef6959df3bc9431680c944c6ca5b1eff",
  "InstanceQueueName": "azure-webjobs-host-ad1f5b26ddec43269cfbdf585065e773",
  "Heartbeat": {
    "SharedContainerName": "azure-webjobs-hosts",
    "SharedDirectoryName": "heartbeats/ef6959df3bc9431680c944c6ca5b1eff",
    "InstanceBlobName": "ad1f5b26ddec43269cfbdf585065e773",
    "ExpirationInSeconds": 45
  }
}

如果删除Singleton属性,则一切正常!

我已经尝试过类似的选项-
[Singleton(@"{CorrelationId}")]

但是,它没有帮助。

有什么问题(和解决方法)?

最佳答案

我相信我看到了一个可以明天解决的错误。目前,您应该能够通过绑定(bind)到自己的POCO类型而不是BrokeredMessage来解决此问题。您现在可以尝试吗?

准备好后,我将通过包含修复程序的更新软件包的链接回复此线程。

谢谢。

关于c# - 在WebJobs SDK中将Singleton属性与ServiceBusTrigger一起使用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32825461/

10-11 02:34