代码永远不会过去调用:eventProcessorHost.RegisterEventProcessorAsync< ListenEventProcessor> [英] Code never get past call to: eventProcessorHost.RegisterEventProcessorAsync<ListenEventProcessor>

查看:140
本文介绍了代码永远不会过去调用:eventProcessorHost.RegisterEventProcessorAsync< ListenEventProcessor>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Azure Event Hub用作SignalR Web应用程序的背板(asp.net mvc,4.5.2).

I am using an Azure Event Hub as backplane for my SignalR Web App (asp.net mvc, 4.5.2).

我在创建可以侦听消息的客户端时遇到了一些问题.该应用程序启动时,整个应用程序的加载将在此行停止.

I have some problems with creating a client that can listen for messages. The loading of the entire application stops at this line when this application start up.

await eventProcessorHost.RegisterEventProcessorAsync<ListenEventProcessor>(options);

我的代码:

public class TCT
{
    // Singleton instance
    private static readonly Lazy<TCT> Instance = new Lazy<TCT>(() => new TCT(GlobalHost.ConnectionManager.GetHubContext<TCHub>().Clients));

    private TCT()
    {
        InitializeEventHubListnerAsync().GetAwaiter().GetResult();
    }

    private async Task InitializeEventHubListnerAsync()
    {
        ...
        var eventProcessorHostName = Guid.NewGuid().ToString();
        var eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

        var options = new EventProcessorOptions();
        options.ExceptionReceived += (sender, e) =>
        {
            ServiceEventSource.Current.Message("Error occured recieveing message " + e.Exception.Message);
        };

        ServiceEventSource.Current.Message("This is the last entry is see in the log file");
        await eventProcessorHost.RegisterEventProcessorAsync<ListenEventProcessor>(options);
        ServiceEventSource.Current.Message("This line is never printet in the logs and the loading of the entire web application stops here.");
    }
}

如果我删除 等待eventProcessorHost.RegisterEventProcessorAsync(options); Web应用程序可以很好地加载,但是当然不会收到任何消息

If i remove await eventProcessorHost.RegisterEventProcessorAsync(options); the web application loads just fine, but does not recieve any messages of course

我在编写代码时使用了本指南 https://docs.microsoft.com/zh-CN/azure/event-hubs/event-hubs-dotnet-standard-getstarted-receive-eph

I used this guide when writing the code https://docs.microsoft.com/en-gb/azure/event-hubs/event-hubs-dotnet-standard-getstarted-receive-eph

推荐答案

我知道SignalR当前不支持Azure Event Hub作为背板.

As I know Azure Event Hub as backplane is not supported by SignalR currently.

SignalR当前提供三个背板:Azure服务总线,Redis,SQL Server.

SignalR currently provides three backplanes: Azure Service Bus,Redis,SQL Server.

以下是文档中的摘录.

Azure服务总线.

服务总线是一种消息传递基础结构,它允许组件以松散耦合的方式发送消息.

Service Bus is a messaging infrastructure that allows components to send messages in a loosely coupled way.

Redis . Redis是一个内存中键值存储. Redis支持用于发送消息的发布/订阅("pub/sub")模式.

Redis. Redis is an in-memory key-value store. Redis supports a publish/subscribe ("pub/sub") pattern for sending messages.

SQL Server . SQL Server底板将消息写入SQL表.底板使用Service Broker进行有效的消息传递.但是,如果未启用Service Broker,它也可以工作

SQL Server. The SQL Server backplane writes messages to SQL tables. The backplane uses Service Broker for efficient messaging. However, it also works if Service Broker is not enabled

有一个打开的问题用于支持Azure EventHub.

There is an opened issue for supporting Azure EventHub.

这篇关于代码永远不会过去调用:eventProcessorHost.RegisterEventProcessorAsync&lt; ListenEventProcessor&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆