我正在尝试使用 EventProcessorHost 在 JAVA 中使用来自 eventthub 的消息。遵循here1和here2给出的步骤,但是当我运行代码时,我遇到了错误..
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
更多细节:
如博客中所述创建了新的存储帐户,还创建了 blob。
EventProcessor 类和 ErrorNotificationHandler 类与 Microsoft 文档中提到的完全相同。
调用寄存器的代码如下...
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()); } }
注意:博客已弃用 EventProcessorHost 的构造函数。
在线搜索错误,我能找到的是增加存储超时,但不确定如何证明 EventProcessorHost 中存储的特定超时。任何帮助表示赞赏。