Receive events from Azure Event Hubs using Java
Note: This sample is available as a tutorial here.
The tutorial walks you through the consuming/receiving events from event hub. The sample uses Event Processor Host for consuming the events. Events in an event hub are distributed in various partitions to achieve parallelism while consuming. EPH simplifies processing events from event hub by managing persistent checkpoints and parallel receives.
To run the sample, you need to edit the sample code and provide the following information:
final String namespaceName = "----EventHubsNamespaceName-----"; final String eventHubName = "----EventHubName-----"; final String sasKeyName = "-----SharedAccessSignatureKeyName-----"; final String sasKey = "---SharedAccessSignatureKey----"; final String storageAccountName = "---StorageAccountName----" final String storageAccountKey = "---StorageAccountKey----";
Please refer to the overview README for prerequisites and setting up the sample environment, including creating an Event Hubs cloud namespace and an Event Hub.
Build and run
The sample can be built independently with
mvn clean package
and then run with (or just from VS Code or another Java IDE)
java -jar ./target/eventprocessorsample-1.0.0-jar-with-dependencies.jar