简体   繁体   English

注册EventProcessorHost时失败

[英]Failure when registering EventProcessorHost

I am trying to use EventProcessorHost to consume messages from eventhub in JAVA. 我正在尝试使用EventProcessorHost来使用JAVA中来自eventhub的消息。 Followed steps which are given here1 and here2 but when I run code I am getting below error.. 遵循了here1here2给出的步骤,但是当我运行代码时,我遇到了以下错误。

 Registering host named <name> Failure while registering: java.util.concurrent.ExecutionException: com.microsoft.azure.storage.StorageException: The client could not finish the operation within specified maximum execution timeout. Press enter to stop 

More details: 更多细节:

  1. Created new storage account as mentioned in blog and also created blob. 如博客中所述创建了新的存储帐户,并且还创建了blob。

  2. EventProcessor class and ErrorNotificationHandler class are exactly as mentioned on Microsoft docs. EventProcessor类和ErrorNotificationHandler类与Microsoft文档中完全相同。

  3. Code which calls register is as below... 调用寄存器的代码如下...

     final String consumerGroupName = "test"; final String namespaceName = "--namespace--"; final String eventHubName = "--eventhub name --"; final String sasKeyName = "--saskey name--"; final String sasKey = "--sas-key"; final String containerName = "--container name --"; final String storageAccountName = "--storage account name --"; final String storageAccountKey = "--storage -- account key--"; final String connectionString = "--eventhub connection string copied from azure portal --"; final String storageConString = "--storage connection string copied from azure portal --"; EventProcessorHost host = new EventProcessorHost( namespaceName, // Also tried with full name <namespace name>.servicebus.windows.net eventHubName, consumerGroupName, connectionString, storageConString, containerName // "<blobprefix>" Also tried with blob prefix ); System.out.println("Registering host named " + host.getHostName()); EventProcessorOptions options = new EventProcessorOptions(); options.setReceiveTimeOut(Duration.ofMinutes(12 L)); options.setExceptionNotification(new ErrorNotificationHandler()); try { host.registerEventProcessor(EventProcessor.class, options).get(15, TimeUnit.MINUTES); } catch (Exception e) { System.out.print("Failure while registering: "); if (e instanceof ExecutionException) { Throwable inner = e.getCause(); System.out.println(inner.toString()); } else { System.out.println(e.toString()); } } 

Note: Blog has deprecated constructor for EventProcessorHost. 注意:Blog已弃用EventProcessorHost的构造函数。

Searched for error online and what I could find is to increase the timeout for storage but not sure how can I prove specific timeout for storage in EventProcessorHost. 在线搜索错误,我能找到的是增加存储超时,但是不确定如何证明EventProcessorHost中存储的特定超时。 Any help appreciated. 任何帮助表示赞赏。

I followed the official document to receive messages from event hub and it works well for me. 我遵循了官方文件,以接收来自活动中心的消息,它对我来说很好用。

在此处输入图片说明

Messages were stored into Azure Blob Storage which I configured. 邮件已存储到我配置的Azure Blob存储中。

在此处输入图片说明

According to your description , the timeout Exception still occurred even though you set the ReceiveTimeOut to 12 mins in EventProcessorOptions. 根据您的描述,即使您在EventProcessorOptions中将ReceiveTimeOut设置为12分钟,仍然会发生超时异常。 Per my experience , even if messages are received one by one, it can't take 12 minutes to do so long. 根据我的经验,即使消息是一一收到的,也不需要花费12分钟的时间。 And it's usually impossible for us to set the timeout so long in our application. 对于我们来说,通常不可能在应用程序中设置如此长的超时时间。 So I think error is no longer from SDK level. 因此,我认为错误不再来自SDK级别。 It may be the network environment issue. 这可能是网络环境问题。

As I know , the Event Hub message send client uses the HTTP protocol and is won't be blocked by the firewall. 据我所知,事件中心消息发送客户端使用HTTP protocol ,不会被防火墙阻止。 The EPH message receive client uses the AMQP protocol which is essentially TCP protocol and is will restricted by proxy server settings or firewall. EPH消息接收客户端使用AMQP协议,该协议本质上是TCP protocol并且受代理服务器设置或防火墙的限制。 I assume your Eph client has no connection to Event hub. 我假设您的Eph客户端与事件中心没有连接。

I do not know your actual network environment,so I suggest you check your proxy settings or firewall white list to troubleshoot issues with the network environment. 我不知道您的实际网络环境,因此建议您检查代理设置或防火墙白名单以解决网络环境问题。

Any concern , please let me know. 如有任何疑问,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM