Azure service fabric 致命错误-具有服务结构的Azure存储队列

Azure service fabric 致命错误-具有服务结构的Azure存储队列,azure-service-fabric,azure-webjobssdk,azure-storage-queues,Azure Service Fabric,Azure Webjobssdk,Azure Storage Queues,我一直在尝试为发布在服务结构内部Azure存储队列上的消息添加侦听器。我在无状态服务中使用的代码片段如下: using System; using System.Collections.Generic; using System.Diagnostics; using System.Fabric; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.WebJob

我一直在尝试为发布在服务结构内部Azure存储队列上的消息添加侦听器。我在无状态服务中使用的代码片段如下:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Fabric;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
using Microsoft.WindowsAzure.Storage.Queue;
using Notification;

namespace My.Notification
{
    /// <summary>
    /// An instance of this class is created for each service instance by the Service Fabric runtime.
    /// </summary>'
    internal sealed class Notification : StatelessService
    {
        public Notification(StatelessServiceContext context)
            : base(context)
        {




        }

        /// <summary>
        /// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests.
        /// </summary>
        /// <returns>A collection of listeners.</returns>
        protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
        {
            return new ServiceInstanceListener[0];
        }

        //First option
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            JobHostConfiguration config = new JobHostConfiguration();
            config.DashboardConnectionString = "string";
            config.StorageConnectionString = "stringg";
            config.Queues.BatchSize = 10;
            config.Queues.MaxDequeueCount = 8;
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(30);
            var host = new JobHost(config);

            //Breaks below
            await host.CallAsync(typeof(Notification).GetMethod("ProcessMethod"), cancellationToken);
            host.RunAndBlock();

        }

        //Second option
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            try
            {
                var config = new JobHostConfiguration
                {
                    DashboardConnectionString = "string",//Real connection string,
                    StorageConnectionString = "string",
                    Queues =
                    {
                        BatchSize = 1,
                        MaxDequeueCount = 3,
                        MaxPollingInterval = TimeSpan.FromSeconds(30)
                    }
                };
                var host = new JobHost(config);

                //Breaks here
                await host.StartAsync(cancellationToken);
            }
            catch (Exception ex)
            {
                //ServiceEventSource.Current.ServiceStartupFailedEvent(ex.ToString());
                throw;
            }
        }

        [NoAutomaticTrigger]
        public static async Task ProcessMethod(CancellationToken cancellationToken)
        {
            long iterations = 0;
            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();
                //log
                Trace.TraceInformation(">>[{0}]ProcessMethod Working-{1}", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"), ++iterations);
                //sleep for 5s
                await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
            }
        }


        //[Timeout("00:03:00")]
        public static void ProcessNotificationsInQueue([QueueTrigger("emailqueue")] string message)
        {
            Trace.TraceInformation(">ProcessNotificationsInQueue invoked with notification:{0}", message);
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用系统诊断;
使用系统、织物;
使用System.Linq;
使用系统线程;
使用System.Threading.Tasks;
使用Microsoft.Azure.WebJobs;
使用Microsoft.ServiceFabric.Services.Communication.Runtime;
使用Microsoft.ServiceFabric.Services.Runtime;
使用Microsoft.WindowsAzure.Storage.Queue;
使用通知;
名称空间My.Notification
{
/// 
///该类的实例由服务结构运行时为每个服务实例创建。
/// '
内部密封类通知:无状态服务
{
公共通知(无状态ServiceContext上下文)
:基本(上下文)
{
}
/// 
///可选覆盖,用于为此服务副本创建侦听器(例如TCP、HTTP),以处理客户端或用户请求。
/// 
///听众的集合。
受保护的重写IEnumerable CreateServiceInstanceListeners()
{
返回新的ServiceInstanceListener[0];
}
//第一选择
受保护的覆盖异步任务RunAsync(CancellationToken CancellationToken)
{
JobHostConfiguration配置=新的JobHostConfiguration();
config.DashboardConnectionString=“string”;
config.StorageConnectionString=“stringg”;
config.Queues.BatchSize=10;
config.Queues.MaxDequeueCount=8;
config.Queues.MaxPollingInterval=TimeSpan.FromSeconds(30);
var host=新作业主机(配置);
//在下面休息
wait host.CallAsync(typeof(Notification).GetMethod(“ProcessMethod”),cancellationToken);
host.RunAndBlock();
}
//第二种选择
受保护的覆盖异步任务RunAsync(CancellationToken CancellationToken)
{
尝试
{
var config=newjobhostconfiguration
{
DashboardConnectionString=“string”,//实际连接字符串,
StorageConnectionString=“字符串”,
排队=
{
BatchSize=1,
MaxDequeueCount=3,
MaxPollingInterval=TimeSpan.FromSeconds(30)
}
};
var host=新作业主机(配置);
//在这里休息
wait host.StartAsync(cancellationToken);
}
捕获(例外情况除外)
{
//ServiceEventSource.Current.ServiceStartupFailedEvent(例如ToString());
投掷;
}
}
[NoAutomaticTrigger]
公共静态异步任务处理方法(CancellationToken CancellationToken)
{
长迭代=0;
while(true)
{
cancellationToken.ThrowIfCancellationRequested();
//日志
Trace.TraceInformation(“>>[{0}]ProcessMethod Working-{1}”,DateTime.UtcNow.ToString(“yyyy-MM-dd-HH:MM:ss”),++迭代);
//睡5秒钟
等待任务延迟(TimeSpan.FromSeconds(5),cancellationToken);
}
}
//[超时(“00:03:00”)]
公共静态void ProcessNotificationsInQueue([QueueTrigger(“emailqueue”)]字符串消息)
{
Trace.TraceInformation(“>ProcessNotificationsInQueue调用通知:{0}”,消息);
}
}
}
我得到的错误如下所示。我已经尝试了这两种方法,我不知道如何获得更多的细节,除此之外。一些帖子建议我们启用mda,我也尝试过。其他人则指出这可能是CLR问题。我也看过这个,我有几乎相同的默认设置


好的,根据讨论找出了解决方案 我的Azure WebJobs版本依赖于存储。存储的版本是9.0.0,其中删除了一个方法。该方法的不可用是导致此次崩溃的原因