我正在测试一个使用Service Bus SDK从事件中心检索消息的.NET Core 2.0应用程序。我设置了一个控制台应用程序来执行该操作,并打算将应用程序作为Docker容器运行。
这种方法创建了事件主机处理器,它将读取消息:
private static async Task MainAsync(string[] args)
{
Console.WriteLine("Registering EventProcessor...");
var eventProcessorHost = new EventProcessorHost(
EhEntityPath,
PartitionReceiver.DefaultConsumerGroupName,
EhConnectionString,
StorageConnectionString,
StorageContainerName);
// Registers the Event Processor Host and starts receiving messages
Console.WriteLine("Retrieving messages");
await eventProcessorHost.RegisterEventProcessorAsync<EventProcessor>();
Console.WriteLine("Sleeping");
Thread.Sleep(Timeout.Infinite);
}
作为在
EventProcessor
类中实现的事件处理器将处理事件的一个,我试图防止控制台应用程序在处理器注册完成后退出。
但是,我找不到可靠的方法来保持应用程序的运行。如果按原样运行此容器,输出窗口中只会看到以下内容:
Registering EventProcessor...
Retrieving messages
Sleeping
并且从未收到任何消息。
EhConnectionString
的值是什么? - Tarun Lalwani