[英]How We can receive event from Azure event hub without Storage Container Name ,StorageAccountName and StorageAccountKey these information
I am new to Azure platform, I have only EventHubConnectionString and EventHubName and I don't have Storage Container Name, StorageAccountName and storage account key.我是 Azure 平台的新手,我只有 EventHubConnectionString 和 EventHubName,我没有存储容器名称、StorageAccountName 和存储帐户密钥。 I want to develop one application which receives events from event hub but I am confused about how should I proceed wihtout this information.Please help with this problem.
我想开发一个从事件中心接收事件的应用程序,但我不知道如何在没有这些信息的情况下进行。请帮助解决这个问题。
I am following this link for reference Azure Event Hub.我正在关注此链接以供参考Azure 事件中心。
I am confused about how should I proceed wihtout this information
我很困惑我应该如何在没有这些信息的情况下进行
It seems that in order to use Event Hub, you are required to have something to manage checkpoints.似乎为了使用事件中心,您需要有一些东西来管理检查点。 Most of the examples and documentation show using Azure Storage to hold the checkpoints that are automatically made by the current .Net Azure SDK code base.
大多数示例和文档显示使用 Azure 存储来保存由当前 .Net Azure SDK 代码库自动创建的检查点。 The current documentation on the EventProcessorHost doesn't appear to show the one of the constructors that does not require a storage account but a custom class that you write that derives from ICheckpointManager .
EventProcessorHost上的当前文档似乎没有显示不需要存储帐户的构造函数之一,而是显示您编写的从ICheckpointManager派生的自定义类。
The constructor that isn't documented (at this point in time) looks like:未记录的构造函数(此时)如下所示:
//
// 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);
You will have to use Custom CheckpointManager for EventProcessorHost (EPH) if you dont want to use default azure checkpoint manager.如果您不想使用默认的 azure 检查点管理器,则必须为 EventProcessorHost (EPH)使用自定义检查点管理器。 Mikhailshilkov has a sample SQL checkpointmanager implementaion.
Mikhailshilkov 有一个示例 SQL 检查点管理器实现。 SQLcheckpointManager Sample
SQLcheckpointManager 示例
You can use EventHubConsumerClient.ReadEventsAsync
.您可以使用
EventHubConsumerClient.ReadEventsAsync
。 To me this is better, because I don't want to use blob storage.对我来说这更好,因为我不想使用 blob 存储。 But I am getting
Error reading event: EventHubsException(ConsumerDisconnected)
from time to time但我
Error reading event: EventHubsException(ConsumerDisconnected)
收到Error reading event: EventHubsException(ConsumerDisconnected)
Refer docs: https://docs.microsoft.com/en-us/java/api/com.azure.messaging.eventhubs?view=azure-java-stable参考文档: https : //docs.microsoft.com/en-us/java/api/com.azure.messaging.eventhubs? view = azure-java- stable
Code snippet :代码片段:
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());
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.