From 54f9a5eb7728c71567c9c8719f82e6d9d0abe7e1 Mon Sep 17 00:00:00 2001 From: Sreeram Kumar Garlapati Date: Fri, 24 Feb 2017 09:47:22 -0800 Subject: [PATCH 1/2] relase readiness for 0.11.0 --- ConsumingEvents.md | 35 +++++++++---------- PublishingEvents.md | 17 +++++---- .../azure/servicebus/ClientConstants.java | 2 +- pom.xml | 2 +- readme.md | 19 +++++----- 5 files changed, 36 insertions(+), 39 deletions(-) diff --git a/ConsumingEvents.md b/ConsumingEvents.md index 6287d0037..741102eb7 100644 --- a/ConsumingEvents.md +++ b/ConsumingEvents.md @@ -30,7 +30,7 @@ following dependency declaration inside of your Maven project file: com.microsoft.azure azure-eventhubs-clients - 0.10.0 + 0.11.0 ``` @@ -57,28 +57,27 @@ The receiver code creates an *EventHubClient* from a given connecting string final String sasKey = "---SharedAccessSignatureKey----"; ConnectionStringBuilder connStr = new ConnectionStringBuilder(namespaceName, eventHubName, sasKeyName, sasKey); - EventHubClient ehClient = EventHubClient.createFromConnectionString(connStr.toString()).get(); + EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString()); ``` -The receiver code then creates (at least) one *PartitionReceiver* that will receive the data. The receiver is seeded with -an offset, in the snippet below it's simply the start of the log. +The receiver code then creates (at least) one *PartitionReceiver* that will receive the data. The receiver is seeded with an offset, in the snippet below it's simply the start of the log. ```Java - String partitionId = "0"; // API to get PartitionIds will be released soon - PartitionReceiver receiver = ehClient.createReceiver( + String partitionId = "0"; + PartitionReceiver receiver = ehClient.createReceiverSync( EventHubClient.DefaultConsumerGroupName, partitionId, PartitionReceiver.StartOfStream, - false).get(); + false); - receiver.setReceiveTimeout(Duration.ofSeconds(5)); + receiver.setReceiveTimeout(Duration.ofSeconds(20)); ``` Once the receiver is initialized, getting events is just a matter of calling the *receive()* method in a loop. Each call to *receive()* will fetch an iterable batch of events to process. ```Java - Iterable receivedEvents = receiver.receive(maxEventCount).get(); + Iterable receivedEvents = receiver.receiveSync(maxEventCount); ``` ##Consumer Groups @@ -111,20 +110,20 @@ begin receiving events: after the given instant. ``` Java - PartitionReceiver receiver = ehClient.createReceiver( + PartitionReceiver receiver = ehClient.createReceiverSync( EventHubClient.DefaultConsumerGroupName, partitionId, - Instant.now()).get(); + Instant.now()); ``` 3. **Absolute offset** This option is commonly used to resume receiving events after a previous receiver on the partition has been aborted or suspended for any reason. The offset is a system-supplied string that should not be interpreted by the application. The next section will discuss scenarios for using this option. ``` Java - PartitionReceiver receiver = ehClient.createReceiver( + PartitionReceiver receiver = ehClient.createReceiverSync( EventHubClient.DefaultConsumerGroupName, partitionId, - savedOffset).get(); + savedOffset); ``` @@ -162,11 +161,11 @@ That mechanism is called **epochs**. An epoch is an integer value that acts as a ``` Java epochValue = 1 - PartitionReceiver receiver1 = ehClient.createEpochReceiver( + PartitionReceiver receiver1 = ehClient.createEpochReceiverSync( EventHubClient.DefaultConsumerGroupName, partitionId, savedOffset, - epochValue).get(); + epochValue); ``` When a new partition owner takes over, it creates a receiver for the same partition, but with a greater epoch value. This will instantly @@ -175,14 +174,14 @@ That mechanism is called **epochs**. An epoch is an integer value that acts as a ``` Java /* obtain checkpoint data */ epochValue = 2 - PartitionReceiver receiver2 = ehClient.createEpochReceiver( + PartitionReceiver receiver2 = ehClient.createEpochReceiverSync( EventHubClient.DefaultConsumerGroupName, partitionId, savedOffset, - epochValue).get(); + epochValue); ``` -The new leader obviously also needs to know at which offset processing shall continue. For this, the current owner of a partition should +The new reader obviously also needs to know at which offset processing shall continue. For this, the current owner of a partition should periodically record its progress on the event stream to a shared location, tracking the offset of the last processed message. This is called "checkpointing". In case of the aforementioned Azure Blob lease election model, the blob itself is a great place to keep this information. diff --git a/PublishingEvents.md b/PublishingEvents.md index 9ab9e111c..87a599b34 100644 --- a/PublishingEvents.md +++ b/PublishingEvents.md @@ -12,7 +12,7 @@ following dependency declaration inside of your Maven project file: com.microsoft.azure azure-eventhubs-clients - 0.10.0 + 0.11.0 ``` @@ -40,7 +40,7 @@ Using an Event Hub connection string, which holds all required connection inform final String sasKey = "---SharedAccessSignatureKey----"; ConnectionStringBuilder connStr = new ConnectionStringBuilder(namespaceName, eventHubName, sasKeyName, sasKey); - EventHubClient ehClient = EventHubClient.createFromConnectionString(connStr.toString()).get(); + EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString()); ``` Once you have the client in hands, you can package any arbitrary payload as a plain array of bytes and send it. The samples @@ -48,12 +48,11 @@ we use to illustrate the functionality send a UTF-8 encoded JSON data, but you c ```Java EventData sendEvent = new EventData(payloadBytes); - ehClient.send(sendEvent).get(); + ehClient.sendSync(sendEvent); ``` The entire client API is built for Java 8's concurrent task model, generally returning -[*CompletableFuture*](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), so the -*.get()* suffixing the operations in the snippets above just wait until the respective operation is complete. +[*CompletableFuture*](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), so the library has these methods suffixed with *Sync* as their Synchronous counterparts/varaints. ##AMQP 1.0 Azure Event Hubs allows for publishing events using the HTTPS and AMQP 1.0 protocols. The Azure Event Hub endpoints @@ -126,7 +125,7 @@ The gesture is a straightforward extra override to the send operation supplying ```Java EventData sendEvent = new EventData(payloadBytes); -> ehClient.send(sendEvent, partitionKey).get(); +> ehClient.sendSync(sendEvent, partitionKey); ``` ####Using Partition Ids @@ -136,10 +135,10 @@ you can send directly to the partition, but doing so requires an extra gesture s option. To send to a partition you explicitly need to create a client object that is tued to the partition as shown below: ```Java - EventHubClient ehClient = EventHubClient.createFromConnectionString(str).get(); -> EventHubSender sender = ehClient.createPartitionSender("0").get(); + EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(str); +> EventHubSender sender = ehClient.createPartitionSenderSync("0"); EventData sendEvent = new EventData(payloadBytes); - sender.send(sendEvent).get(); + sender.sendSync(sendEvent); ``` #### Publisher Policies diff --git a/azure-eventhubs/src/main/java/com/microsoft/azure/servicebus/ClientConstants.java b/azure-eventhubs/src/main/java/com/microsoft/azure/servicebus/ClientConstants.java index f9d88cf10..83cc67081 100644 --- a/azure-eventhubs/src/main/java/com/microsoft/azure/servicebus/ClientConstants.java +++ b/azure-eventhubs/src/main/java/com/microsoft/azure/servicebus/ClientConstants.java @@ -52,7 +52,7 @@ private ClientConstants() { } public final static String DEFAULT_RETRY = "Default"; public final static String PRODUCT_NAME = "MSJavaClient"; - public final static String CURRENT_JAVACLIENT_VERSION = "0.11.0-SNAPSHOT"; + public final static String CURRENT_JAVACLIENT_VERSION = "0.11.0"; public static final String PLATFORM_INFO = getPlatformInfo(); diff --git a/pom.xml b/pom.xml index 6a32d5dc1..5f0b7aad8 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ 0.16.0 4.12 - 0.11.0-SNAPSHOT + 0.11.0 diff --git a/readme.md b/readme.md index 584f82a8a..6fa44af8e 100644 --- a/readme.md +++ b/readme.md @@ -62,19 +62,18 @@ you then create an *EventHubClient* instance, which manages a secure AMQP 1.0 co final String sasKey = "---SharedAccessSignatureKey----"; ConnectionStringBuilder connStr = new ConnectionStringBuilder(namespaceName, eventHubName, sasKeyName, sasKey); - EventHubClient ehClient = EventHubClient.createFromConnectionString(connStr.toString()).get(); + EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString()); ``` Once you have the client in hands, you can package any arbitrary payload as a plain array of bytes and send it. ```Java EventData sendEvent = new EventData(payloadBytes); - ehClient.send(sendEvent).get(); + ehClient.sendSync(sendEvent); ``` The entire client API is built for Java 8's concurrent task model, generally returning -[*CompleteableFuture*](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), so the -*.get()* suffixing the operations in the snippets above just wait until the respective operation is complete. +[*CompleteableFuture*](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), so the library has these methods suffixed with *Sync* as their Synchronous counterparts/varaints. Learn more about publishing events, including advanced options, and when you should and shouldn't use those options, [in the event publisher guide](PublishingEvents.md). @@ -104,7 +103,7 @@ Just like the sender, the receiver code imports the package and creates an *Even final String sasKey = "---SharedAccessSignatureKey----"; ConnectionStringBuilder connStr = new ConnectionStringBuilder(namespaceName, eventHubName, sasKeyName, sasKey); - EventHubClient ehClient = EventHubClient.createFromConnectionString(connStr.toString()).get(); + EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString()); ``` The receiver code then creates (at least) one *PartitionReceiver* that will receive the data. The receiver is seeded with @@ -112,20 +111,20 @@ an offset, in the snippet below it's simply the start of the log. ```Java String partitionId = "0"; // API to get PartitionIds will be released as part of V0.2 - PartitionReceiver receiver = ehClient.createReceiver( + PartitionReceiver receiver = ehClient.createReceiverSync( EventHubClient.DefaultConsumerGroupName, partitionId, PartitionReceiver.StartOfStream, - false).get(); + false); - receiver.setReceiveTimeout(Duration.ofSeconds(5)); + receiver.setReceiveTimeout(Duration.ofSeconds(20)); ``` Once the receiver is initialized, getting events is just a matter of calling the *receive()* method in a loop. Each call to *receive()* will fetch an enumerable batch of events to process. ```Java - Iterable receivedEvents = receiver.receive(maxEventsCount).get(); + Iterable receivedEvents = receiver.receiveSync(maxEventsCount); ``` As you might imagine, there's quite a bit more to know about partitions, about distributing the workload of processing huge and @@ -148,7 +147,7 @@ the required version of Apache Qpid Proton-J, and the crytography library BCPKIX com.microsoft.azure azure-eventhubs - 0.10.0 + 0.11.0 ``` From e83abd69ba3c3a191c6b122fd06a26c6c74fff3b Mon Sep 17 00:00:00 2001 From: Sreeram Kumar Garlapati Date: Fri, 24 Feb 2017 09:50:53 -0800 Subject: [PATCH 2/2] doc edit --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 6fa44af8e..70f21eb44 100644 --- a/readme.md +++ b/readme.md @@ -110,7 +110,7 @@ The receiver code then creates (at least) one *PartitionReceiver* that will rece an offset, in the snippet below it's simply the start of the log. ```Java - String partitionId = "0"; // API to get PartitionIds will be released as part of V0.2 + String partitionId = "0"; PartitionReceiver receiver = ehClient.createReceiverSync( EventHubClient.DefaultConsumerGroupName, partitionId,