PartitionReceiver (Azure SDK for Java Reference Documentation)

Sample code (sample uses sync version of the api but concept are identical):

Receive a batch of EventData's from an EventHub partition

Sample code (sample uses sync version of the api but concept are identical):

 EventHubClient client = EventHubClient.createSync("__connection__"); PartitionReceiver receiver = client.createPartitionReceiverSync("ConsumerGroup1", "1"); Iterable<EventData> receivedEvents = receiver.receiveSync(); while (true) { int batchSize = 0; if (receivedEvents != null) { for(EventData receivedEvent: receivedEvents) { System.out.println(String.format("Message Payload: %s", new String(receivedEvent.getBytes(), Charset.defaultCharset()))); System.out.println(String.format("Offset: %s, SeqNo: %s, EnqueueTime: %s", receivedEvent.getSystemProperties().getOffset(), receivedEvent.getSystemProperties().getSequenceNumber(), receivedEvent.getSystemProperties().getEnqueuedTime())); batchSize++; } } System.out.println(String.format("ReceivedBatch Size: %s", batchSize)); receivedEvents = receiver.receiveSync(); } 

ncG1vNJzZmiZqqq%2Fpr%2FDpJuom6Njr627wWeaqKqVY8SqusOorqxmnprBcHDWnploopGrrnCt2a6pnmWVq7KvwMeumaxnY2OAb3yOnKamZ52esLO70qidrWeRr8KzsY6erZ6mpJ3Co7%2BOiZirrJmptrC6sZ6anqGmmr9vtNOmow%3D%3D

 Share!