Skip to content

Commit 5752d3a

Browse files
authored
Merge pull request #14015 from izzyacademy/patch-2
Update to EPH Java Documentation
2 parents 78e9784 + 4cdd3d4 commit 5752d3a

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

articles/event-hubs/event-hubs-java-get-started-receive-eph.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: timlt
88
ms.service: event-hubs
99
ms.workload: core
1010
ms.topic: article
11-
ms.date: 08/12/2018
11+
ms.date: 08/26/2018
1212
ms.author: shvija
1313

1414
---
@@ -51,18 +51,18 @@ To use EventProcessorHost, you must have an [Azure Storage account][Azure Storag
5151

5252
### Create a Java project using the EventProcessor Host
5353

54-
The Java client library for Event Hubs is available for use in Maven projects from the [Maven Central Repository][Maven Package], and can be referenced using the following dependency declaration inside your Maven project file. The current version is 1.0.0:
54+
The Java client library for Event Hubs is available for use in Maven projects from the [Maven Central Repository][Maven Package], and can be referenced using the following dependency declaration inside your Maven project file. The current version is for the artifact azure-eventhubs-eph is 2.0.1 and the current version for the artifact azure-eventhubs is 1.0.2:
5555

5656
```xml
5757
<dependency>
5858
<groupId>com.microsoft.azure</groupId>
5959
<artifactId>azure-eventhubs</artifactId>
60-
<version>1.0.0</version>
60+
<version>1.0.2</version>
6161
</dependency>
6262
<dependency>
6363
<groupId>com.microsoft.azure</groupId>
6464
<artifactId>azure-eventhubs-eph</artifactId>
65-
<version>1.0.0</version>
65+
<version>2.0.1</version>
6666
</dependency>
6767
```
6868

@@ -240,6 +240,46 @@ For different types of build environments, you can explicitly obtain the latest
240240

241241
This tutorial uses a single instance of EventProcessorHost. To increase throughput, it is recommended that you run multiple instances of EventProcessorHost, preferably on separate machines. This provides redundancy as well. In those cases, the various instances automatically coordinate with each other in order to load balance the received events. If you want multiple receivers to each process *all* the events, you must use the **ConsumerGroup** concept. When receiving events from different machines, it might be useful to specify names for EventProcessorHost instances based on the machines (or roles) in which they are deployed.
242242

243+
## Publishing Messages to EventHub
244+
245+
Before messages are retrieved by consumers, they have to be published to the partitions first by the publishers. It is worth noting that when messages are published to event hub synchronously using the sendSync() method on the com.microsoft.azure.eventhubs.EventHubClient object, the message could be sent to a specific partition or distributed to all available partitions in a round-robin manner depending on whether the partition key is specified or not.
246+
247+
When a string representing the partition key is specified, the key will be hashed to determine which partition to send the event to.
248+
249+
When the partition key is not set, then messages will round-robined to all available partitions
250+
251+
```java
252+
// Serialize the event into bytes
253+
byte[] payloadBytes = gson.toJson(messagePayload).getBytes(Charset.defaultCharset());
254+
255+
// Use the bytes to construct an {@link EventData} object
256+
EventData sendEvent = EventData.create(payloadBytes);
257+
258+
// Transmits the event to event hub without a partition key
259+
// If a partition key is not set, then we will round-robin to all topic partitions
260+
eventHubClient.sendSync(sendEvent);
261+
262+
// the partitionKey will be hash'ed to determine the partitionId to send the eventData to.
263+
eventHubClient.sendSync(sendEvent, partitionKey);
264+
265+
```
266+
267+
## Implementing a Custom CheckpointManager for EventProcessorHost (EPH)
268+
269+
The API provides a mechanism to implement your custom checkpoint manager for scenarios where the default implementation is not compatible with your use case.
270+
271+
The default checkpoint manager uses blob storage but if you override the checkpoint manager used by EPH with your own implementation, you can use any store you want to back the your checkpoint manager implementation.
272+
273+
You have to create a class that implements the interface com.microsoft.azure.eventprocessorhost.ICheckpointManager
274+
275+
Use your custom implementation of the checkpoint manager (com.microsoft.azure.eventprocessorhost.ICheckpointManager)
276+
277+
Within your implementation, you can override the default checkpointing mechanism and implement our own checkpoints based on your own data store (SQL Server, CosmosDB, Redis Cache etc). It is recommended that the store used to back your checkpoint manager implementation be accessible to all EPH instances that are processing events for the consumer group.
278+
279+
You can use any datastore that will be available in your environment.
280+
281+
The com.microsoft.azure.eventprocessorhost.EventProcessorHost class provides you with 2 constructors that allow you to override the checkpoint manager for your EventProcessorHost.
282+
243283
## Next steps
244284

245285
You can learn more about Event Hubs by visiting the following links:
@@ -257,4 +297,4 @@ You can learn more about Event Hubs by visiting the following links:
257297
<!-- Images -->
258298
[11]: ./media/service-bus-event-hubs-get-started-receive-ephjava/create-eph-csharp2.png
259299
[12]: ./media/service-bus-event-hubs-get-started-receive-ephjava/create-eph-csharp3.png
260-
[free account]: https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio
300+
[free account]: https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio

0 commit comments

Comments
 (0)