Closed i-am-rashmi closed 3 years ago
EventProcessorHost host = new EventProcessorHost(
EventProcessorHost.createHostName(hostNamePrefix),
eventHubName,
consumerGroupName,
eventHubConnectionString,
storageConnectionString,
storageContainerName);
System.out.println("Registering host named " + host.getHostName());
EventProcessorOptions options = new EventProcessorOptions();
// options.setExceptionNotification(new ErrorNotificationHandler());
host.registerEventProcessor(EventProcessor.class, options)
.whenComplete((unused, e) ->
{
if (e != null) {
System.out.println("Failure while registering: " + e.toString());
if (e.getCause() != null) {
System.out.println("Inner exception: " + e.getCause().toString());
}
}
})
.thenAccept((unused) ->
{
System.out.println("Press enter to stop.");
try
{
System.out.println("Before in.read()");
System.in.read();
System.out.println("After in.read()");
} catch (Exception e) {
System.out.println("Keyboard read failed: " + e.toString());
}
})
.thenCompose((unused) ->
{
return host.unregisterEventProcessor();
})
.exceptionally((e) ->
{
System.out.println("Failure while unregistering: " + e.toString());
if (e.getCause() != null) {
System.out.println("Inner exception: " + e.getCause().toString());
}
return null;
})
.get(); // Wait for everything to finish before exiting main!
System.out.println("End of sample");
}
This sounds like System.in.read() is not blocking, which is not an Event Hubs issue.
This client is now legacy and in maintenance mode. We will not be adding new features. You can find the new Java Event Hubs client at https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/eventhubs/azure-messaging-eventhubs
Actual Behavior
Registering host named
Press enter to stop.
Before in.read()
After in.read()
End of sample
Expected Behavior
Registering host named
Versions