Azure / azure-event-hubs-java

☁️ Java client library for Azure Event Hubs
https://azure.microsoft.com/services/event-hubs
MIT License
51 stars 61 forks source link

Azure event Hub Processor closes when running on server. But works fine in local #453

Closed i-am-rashmi closed 3 years ago

i-am-rashmi commented 5 years ago

Actual Behavior

  1. Registering host named Press enter to stop. Before in.read() After in.read() End of sample

Expected Behavior

Registering host named

  1. Press enter to stop. Before in.read() Partition 0 is opening

Versions

i-am-rashmi commented 5 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");
}
JamesBirdsall commented 3 years ago

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