PartitionReceiver (Azure SDK for Java Reference Documentation)
Leah Mitchell
Published Feb 16, 2026
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(); }