C# 在没有存储容器名称、StorageAccountName和StorageAccountKey这些信息的情况下,我们如何从Azure事件中心接收事件
我是Azure平台的新手,我只有EventHubConnectionString和EventHubName,没有存储容器名称、StorageAccountName和存储帐户密钥。 我想开发一个从event hub接收事件的应用程序,但我不知道如何在没有这些信息的情况下继续。请帮助解决这个问题 我下面的链接仅供参考 我不知道在没有这些信息的情况下应该如何进行 似乎为了使用事件中心,您需要一些东西来管理检查点。大多数示例和文档显示使用Azure存储来保存由当前.Net Azure SDK代码库自动创建的检查点。上的当前文档似乎没有显示不需要存储帐户但需要从中派生的自定义类的构造函数之一 未记录的构造函数(此时)如下所示:C# 在没有存储容器名称、StorageAccountName和StorageAccountKey这些信息的情况下,我们如何从Azure事件中心接收事件,c#,azure,azure-eventhub,C#,Azure,Azure Eventhub,我是Azure平台的新手,我只有EventHubConnectionString和EventHubName,没有存储容器名称、StorageAccountName和存储帐户密钥。 我想开发一个从event hub接收事件的应用程序,但我不知道如何在没有这些信息的情况下继续。请帮助解决这个问题 我下面的链接仅供参考 我不知道在没有这些信息的情况下应该如何进行 似乎为了使用事件中心,您需要一些东西来管理检查点。大多数示例和文档显示使用Azure存储来保存由当前.Net Azure SDK代码库自动创
//
// Summary:
// Create a new host to process events from an Event Hub.
// This overload of the constructor allows maximum flexibility. This one allows
// the caller to specify the name of the processor host as well. The overload also
// allows the caller to provide their own lease and checkpoint managers to replace
// the built-in ones based on Azure Storage.
//
// Parameters:
// hostName:
// Name of the processor host. MUST BE UNIQUE. Strongly recommend including a Guid
// to ensure uniqueness.
//
// eventHubPath:
// The name of the EventHub.
//
// consumerGroupName:
// The name of the consumer group within the Event Hub.
//
// eventHubConnectionString:
// Connection string for the Event Hub to receive from.
//
// checkpointManager:
// Object implementing ICheckpointManager which handles partition checkpointing.
//
// leaseManager:
// Object implementing ILeaseManager which handles leases for partitions.
public EventProcessorHost(string hostName, string eventHubPath, string consumerGroupName, string eventHubConnectionString, ICheckpointManager checkpointManager, ILeaseManager leaseManager);
我不知道在没有这些信息的情况下应该如何进行
似乎为了使用事件中心,您需要一些东西来管理检查点。大多数示例和文档显示使用Azure存储来保存由当前.Net Azure SDK代码库自动创建的检查点。上的当前文档似乎没有显示不需要存储帐户但需要从中派生的自定义类的构造函数之一
未记录的构造函数(此时)如下所示:
//
// Summary:
// Create a new host to process events from an Event Hub.
// This overload of the constructor allows maximum flexibility. This one allows
// the caller to specify the name of the processor host as well. The overload also
// allows the caller to provide their own lease and checkpoint managers to replace
// the built-in ones based on Azure Storage.
//
// Parameters:
// hostName:
// Name of the processor host. MUST BE UNIQUE. Strongly recommend including a Guid
// to ensure uniqueness.
//
// eventHubPath:
// The name of the EventHub.
//
// consumerGroupName:
// The name of the consumer group within the Event Hub.
//
// eventHubConnectionString:
// Connection string for the Event Hub to receive from.
//
// checkpointManager:
// Object implementing ICheckpointManager which handles partition checkpointing.
//
// leaseManager:
// Object implementing ILeaseManager which handles leases for partitions.
public EventProcessorHost(string hostName, string eventHubPath, string consumerGroupName, string eventHubConnectionString, ICheckpointManager checkpointManager, ILeaseManager leaseManager);
如果不想使用默认的azure检查点管理器,则必须使用。Mikhailshilkov有一个示例SQL检查点管理器实现。如果不想使用默认的azure检查点管理器,则必须使用。Mikhailshilkov有一个示例SQL checkpointmanager实现。您可以使用
EventHubConsumerClient.ReadEventsAsync
。对我来说这更好,因为我不想使用blob存储。但我会不时收到错误读取事件:EventHubsException(ConsumerDisconnected)
您可以使用EventHubsConsumerClient.ReadEventsAsSync
。对我来说这更好,因为我不想使用blob存储。但我不时收到错误读取事件:EventHubsException(ConsumerDisconnected)
参考文档:
代码段:
EventHubConsumerAsyncClient consumer = new EventHubClientBuilder()
.connectionString(connectionStr,eventhubName)
.consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME)
.buildAsyncConsumerClient();
// Receive data for partition "0"
consumer.receiveFromPartition("0", EventPosition.latest()).subscribe(event -> {
System.out.println("Event received : "+event.getData().getBodyAsString());
});
参考文件:
代码段:
EventHubConsumerAsyncClient consumer = new EventHubClientBuilder()
.connectionString(connectionStr,eventhubName)
.consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME)
.buildAsyncConsumerClient();
// Receive data for partition "0"
consumer.receiveFromPartition("0", EventPosition.latest()).subscribe(event -> {
System.out.println("Event received : "+event.getData().getBodyAsString());
});
存储帐户名称和密钥位于azure门户中您的存储帐户实例的“访问密钥”选项卡下。我投票将此问题视为离题,因为它是关于在azure的web门户中定位值的,而不是编程。我认为此问题非常相关,也不是离题。我相信问题是,我如何才能在不使用Azure存储的情况下编写Azure Event Hub事件的消费者。存储帐户名称和密钥位于Azure门户中存储帐户实例的“访问密钥”选项卡下。我投票关闭此问题,因为它是关于在Azure的web门户中查找值的,不是编程。我认为这个问题非常相关,也不是离题。我相信问题是,我如何才能在不使用Azure存储的情况下编写Azure事件中心事件的消费者。感谢Erik提供此信息,由于我对这个平台和C#都是新手,因此我无法在没有存储信息的情况下连接到Azure Event hub来接收消息。如果您提供完整的连接代码,这将对我有很大帮助。还建议我参考一些内容来学习这些概念。我没有示例,但还有很多。至于没有Azure存储的具体示例,这是如何做到的,但我从未实现过。至于参考资料,我强烈建议google.com。谢谢Erik,我找到了一个工具,可以做我想要的类似的事情,但我不知道如何获得这个案例的代码。谢谢Erik提供的信息,由于我对这个平台和C#都是新手,因此我无法在没有存储信息的情况下连接到Azure Event hub来接收消息。如果您提供完整的连接代码,这将对我有很大帮助。还建议我参考一些内容来学习这些概念。我没有示例,但还有很多。至于没有Azure存储的具体示例,这是如何做到的,但我从未实现过。至于参考资料,我强烈建议google.com。谢谢Erik,我找到了一个工具,可以做一些我想要的类似的事情,但我不知道如何获得这个案例的代码