Skip to content

Commit 9cc2dc8

Browse files
authored
Merge latest changes from Azure/azure-event-hubs#444 (#3511)
* Update Apache Proton-J dependency (0.29.0 --> 0.31.0) (#407) * PartitionReceiver - add a method that provides an EventPosition which corresponds to an EventData returned last by the receiver (#408) * Support IsPartitionEmpty property for PartitionRuntimeInformation (#399) * Move setPrefetchCount API to the ReceiverOptions class from the PartitionReceiver and update the settings of Default & Max Prefetch count (#410) This pull request includes two major changes related to Prefetch API. 1) Move setPrefetchCount API to the ReceiverOptions class so that prefetch value specified by a user can be used instead of using default value when communicating to the service during link open and initializing a receiver. This change also addresses the receiver stuck issue caused by setPrefetchAPI in a race condition. 2) Change the default value and set the upper bound of the prefetch count. Note that prefetch count should be greater than or equal to maxEventCount which can be set when either a) calling receive() API or b) implementing the getMaxEventCount API of the SessionReceiverHandler interface. * Fixes several issues in the reactor related components (#411) This pull request contains the following changes. 1) Finish pending tasks when recreating the reactor and make sure pending calls scheduled on the old reactor get complete. 2) Fix the session open timeout issue which can result in NPE in proton-J engine. 3) Make session open timeout configurable and use the value of OperationTimeout. 4) Update the message of exceptions and include an entity name in the exception message. 5) API change - use ScheduledExecutorService. 6) Improve tracing. * Implement comparable on EventData (#395) * Update receive/send link creation logic and improve tracing (#414) * Prep for releasing client 2.0.0 and EPH 2.2.0 (#415) * Ensure that links are closed when transport error occurrs (#417) * ensure links are recreated on transport/connection failure * update API document for EventProcessorOptions class * add traces for link create/close case * Prep for releasing client 2.1.0 and EPH 2.3.0 (#418) * Update prefetch sendflow logic and increment version for new release (#420) * Fix args for proxy auth call to Authenticator (#421) * Prepare EPH 2.3.4 release (#423) * Prepare EPH 2.4.0 release (#423) (#424) * Handle proton:io errors with meaningful error msg (#427) * Handle proton:io errors with meaningful error msg * Use Proton-supplied message if present * Minor changes to lease scanner (#428) * Add logging if the scanner threw an exception. * Change logging level to warn when scanner shuts down for any reason. * Scanner can call EventProcessorOptions.notifyOfException, which calls user code. Change notifyOfException to defensively catch any exceptions coming out of user code. * Make EventData.SystemProperties completely public (#435) Porting testability changes from .NET Core to Java: provide full access to EventData's SystemProperties so that a complete EventData can be fabricated in tests. * Digest Support: init first connection with null headers (#431) Related to Azure/qpid-proton-j-extensions#10 * Fix lease scanner issues when Storage unreachable (#434) This fix is for issue #432. There are two parts: AzureStorageCheckpointLeaseManager performs certain Storage actions within a forEach. If those actions fail, the StorageException gets wrapped in a NoSuchElementException. Catch those and strip off the NoSuchElementException, then handle the StorageException in the existing way. The unexpected NoSuchElementExceptions were not being caught anywhere and the scanner thread was dying without rescheduling itself. Added code in PartitionMananger.scan to catch any exceptions that leak out of PartitionScanner and reschedule the scanner unless the host instance is shutting down. * message receiver - fix null pointer error and ensure that receive link is recreated upon a failure (#439) * message receiver/sender - fix null pointer error and ensure that receive/send link is recreated on a failure. * Update version numbers for release (#440) * Update prefetch count for a receiver (#441) * Fix an issue of creating multiple sessions for $management & $cbs channel for a single connection and improve logging (#443) * Fix an issue of creating multiple sessions for $management & $cbs for a connection and improve logging * Update version numbers for new release (#444) * Update spotbugs.xml report versions
1 parent 0f05332 commit 9cc2dc8

File tree

10 files changed

+194
-194
lines changed

10 files changed

+194
-194
lines changed

eng/spotbugs-aggregate-report/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
<properties>
1818
<azure-batch.version>5.0.1</azure-batch.version>
19-
<azure-eventhubs.version>2.3.0</azure-eventhubs.version>
20-
<azure-eventhubs-eph.version>2.5.0</azure-eventhubs-eph.version>
19+
<azure-eventhubs.version>2.3.1</azure-eventhubs.version>
20+
<azure-eventhubs-eph.version>2.5.1</azure-eventhubs-eph.version>
2121
<azure-keyvault.version>1.2.0</azure-keyvault.version>
2222
<azure-servicebus.version>2.0.0</azure-servicebus.version>
2323
<azure-storage-blob.version>10.5.0</azure-storage-blob.version>

eventhubs/data-plane/ConsumingEvents.md

+103-103
Large diffs are not rendered by default.
+65-65
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# Publishing Events with the Java client for Azure Event Hubs
1+
# Publishing Events with the Java client for Azure Event Hubs
22

3-
The vast majority of Event Hub applications using this and the other client libraries are and will be event publishers.
3+
The vast majority of Event Hub applications using this and the other client libraries are and will be event publishers.
44
And for most of these publishers, publishing events is extremely simple and handled with just a few API gestures.
55

66
## Getting Started
77

88
This library is available for use in Maven projects from the Maven Central Repository, and can be referenced using the
9-
following dependency declaration inside of your Maven project file:
9+
following dependency declaration inside of your Maven project file:
1010

1111
```XML
1212
<dependency>
13-
<groupId>com.microsoft.azure</groupId>
13+
<groupId>com.microsoft.azure</groupId>
1414
<artifactId>azure-eventhubs</artifactId>
15-
<version>2.3.0</version>
15+
<version>2.3.1</version>
1616
</dependency>
1717
```
18-
19-
For different types of build environments, the latest released JAR files can also be [explicitly obtained from the
20-
Maven Central Repository](https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22azure-eventhubs%22) or from [the Release distribution point on GitHub](https://github.com/Azure/azure-event-hubs/releases).
18+
19+
For different types of build environments, the latest released JAR files can also be [explicitly obtained from the
20+
Maven Central Repository](https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22azure-eventhubs%22) or from [the Release distribution point on GitHub](https://github.com/Azure/azure-event-hubs/releases).
21+
22+
23+
For a simple event publisher, you'll need to import the *com.microsoft.azure.eventhubs* package for the Event Hub client classes.
2124

2225

23-
For a simple event publisher, you'll need to import the *com.microsoft.azure.eventhubs* package for the Event Hub client classes.
24-
25-
2626
```Java
2727
import com.microsoft.azure.eventhubs.*;
2828
```
2929

30-
Event Hubs client library uses qpid proton reactor framework which exposes AMQP connection and message delivery related
30+
Event Hubs client library uses qpid proton reactor framework which exposes AMQP connection and message delivery related
3131
state transitions as reactive events. In the process,
3232
the library will need to run many asynchronous tasks while sending and receiving messages to Event Hubs.
3333
So, `EventHubClient` requires an instance of `Executor`, where all these tasks are run.
@@ -37,63 +37,63 @@ So, `EventHubClient` requires an instance of `Executor`, where all these tasks a
3737
ScheduledExecutorService executor = Executors.newScheduledThreadPool(8)
3838
```
3939

40-
Using an Event Hub connection string, which holds all required connection information including an authorization key or token
41-
(see [Connection Strings](#connection-strings)), you then create an *EventHubClient* instance.
42-
40+
Using an Event Hub connection string, which holds all required connection information including an authorization key or token
41+
(see [Connection Strings](#connection-strings)), you then create an *EventHubClient* instance.
42+
4343
```Java
4444
ConnectionStringBuilder connStr = new ConnectionStringBuilder()
4545
.setNamespaceName("----ServiceBusNamespaceName-----")
4646
.setEventHubName("----EventHubName-----")
4747
.setSasKeyName("-----SharedAccessSignatureKeyName-----")
48-
.setSasKey("---SharedAccessSignatureKey----");
49-
48+
.setSasKey("---SharedAccessSignatureKey----");
49+
5050
EventHubClient ehClient = EventHubClient.createSync(connStr.toString(), executor);
5151
```
5252

53-
Once you have the client in hands, you can package any arbitrary payload as a plain array of bytes and send it. The samples
54-
we use to illustrate the functionality send a UTF-8 encoded JSON data, but you can transfer any format you wish.
53+
Once you have the client in hands, you can package any arbitrary payload as a plain array of bytes and send it. The samples
54+
we use to illustrate the functionality send a UTF-8 encoded JSON data, but you can transfer any format you wish.
5555

5656
```Java
5757
EventData sendEvent = EventData.create(payloadBytes);
5858
ehClient.sendSync(sendEvent);
5959
```
60-
61-
The entire client API is built for Java 8's concurrent task model, generally returning
60+
61+
The entire client API is built for Java 8's concurrent task model, generally returning
6262
[*CompletableFuture<T>*](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.
6363

6464
## AMQP 1.0
6565
Azure Event Hubs allows for publishing events using the HTTPS and AMQP 1.0 protocols. The Azure Event Hub endpoints
66-
also support AMQP over the WebSocket protocol, allowing event traffic to leverage the same outbound TCP port as
67-
HTTPS.
66+
also support AMQP over the WebSocket protocol, allowing event traffic to leverage the same outbound TCP port as
67+
HTTPS.
6868

69-
This client library is built on top of the [Apache Qpid Proton-J]() libraries and supports AMQP, which is significantly
70-
more efficient at publishing event streams than HTTPS. AMQP 1.0 is an international standard published as ISO/IEC 19464:2014.
69+
This client library is built on top of the [Apache Qpid Proton-J]() libraries and supports AMQP, which is significantly
70+
more efficient at publishing event streams than HTTPS. AMQP 1.0 is an international standard published as ISO/IEC 19464:2014.
7171

72-
AMQP is session-oriented and sets up the required addressing information and authorization information just once for each
73-
send link, while HTTPS requires doing so with each sent message. AMQP also has a compact binary format to express common
74-
event properties, while HTTPS requires passing message metadata in a verbose text format. AMQP can also keep a significant
75-
number of events "in flight" with asynchronous and robust acknowledgement flow, while HTTPS enforces a strict request-reply
72+
AMQP is session-oriented and sets up the required addressing information and authorization information just once for each
73+
send link, while HTTPS requires doing so with each sent message. AMQP also has a compact binary format to express common
74+
event properties, while HTTPS requires passing message metadata in a verbose text format. AMQP can also keep a significant
75+
number of events "in flight" with asynchronous and robust acknowledgement flow, while HTTPS enforces a strict request-reply
7676
pattern.
7777

78-
AMQP 1.0 is a TCP based protocol. For Azure Event Hubs, all traffic *must* be protected using TLS (SSL) and is using
79-
TCP port 5671.
78+
AMQP 1.0 is a TCP based protocol. For Azure Event Hubs, all traffic *must* be protected using TLS (SSL) and is using
79+
TCP port 5671.
8080

8181
This library will provide HTTPS support via WebSockets when Proton-J supports HTTPS.
8282

8383
## Connection Strings
8484

8585
Azure Event Hubs and Azure Service Bus share a common format for connection strings. A connection string holds all required
86-
information to set up a connection with an Event Hub. The format is a simple property/value list of the form
87-
{property}={value} with pairs separated by ampersands (&).
86+
information to set up a connection with an Event Hub. The format is a simple property/value list of the form
87+
{property}={value} with pairs separated by ampersands (&).
8888

8989
| Property | Description |
90-
|-----------------------|------------------------------------------------------------|
90+
|-----------------------|------------------------------------------------------------|
9191
| Endpoint | URI for the Event Hubs namespace. Typically has the form *sb://{namespace}.servicebus.windows.net/* |
92-
| EntityPath | Relative path of the Event Hub in the namespace. Commonly this is just the Event Hub name |
92+
| EntityPath | Relative path of the Event Hub in the namespace. Commonly this is just the Event Hub name |
9393
| SharedAccessKeyName | Name of a Shared Access Signature rule configured for the Event Hub or the Event Hub name. For publishers, the rule must include "Send" permissions. |
9494
| SharedAccessKey | Base64-encoded value of the Shared Access Key for the rule |
9595
| SharedAccessSignature | A previously issued Shared Access Signature token (not yet supported; will be soon) |
96-
96+
9797
A connection string will therefore have the following form:
9898

9999
```
@@ -102,42 +102,42 @@ A connection string will therefore have the following form:
102102

103103
## Advanced Operations
104104

105-
The publisher example shown in the overview above sends an event into the Event Hub without further qualification. This is
106-
the preferred and most flexible and reliable option. For specific needs, Event Hubs offers two extra options to
107-
qualify send operations: Publisher policies and partion addressing.
105+
The publisher example shown in the overview above sends an event into the Event Hub without further qualification. This is
106+
the preferred and most flexible and reliable option. For specific needs, Event Hubs offers two extra options to
107+
qualify send operations: Publisher policies and partion addressing.
108108

109109
### Partition Addressing
110110

111-
Any Event Hub's event store is split up into at least 4 partitions, each maintaining a separate event log. You can think
112-
of partitions like lanes on a highway. The more events the Event Hub needs to handle, the more lanes (partitions) you have
113-
to add. Each partition can handle at most the equivalent of 1 "throughput unit", equivalent to at most 1000 events per
111+
Any Event Hub's event store is split up into at least 4 partitions, each maintaining a separate event log. You can think
112+
of partitions like lanes on a highway. The more events the Event Hub needs to handle, the more lanes (partitions) you have
113+
to add. Each partition can handle at most the equivalent of 1 "throughput unit", equivalent to at most 1000 events per
114114
second and at most 1 Megabyte per second.
115115

116116
In some cases, publisher applications need to address partitions directly in order to pre-categorize events for consumption.
117-
A partition is directly addressed either by using the partition's identifier or by using some string (partition key) that gets
117+
A partition is directly addressed either by using the partition's identifier or by using some string (partition key) that gets
118118
consistently hashed to a particular partition.
119119

120-
This capability, paired with a large number of partitions, may appear attractive for implementing a fine grained, per publisher
120+
This capability, paired with a large number of partitions, may appear attractive for implementing a fine grained, per publisher
121121
subscription scheme similar to what Topics offer in Service Bus Messaging - but it's not at all how the capability should be used
122-
and it's likely not going to yield satisfying results.
123-
124-
Partition addressing is designed as a routing capability that consistently assigns events from the same sources to the same partition allowing
125-
downstream consumer systems to be optimized, but under the assumption of very many of such sources (hundreds, thousands) share
126-
the same partition. If you need fine-grained content-based routing, Service Bus Topics might be the better option.
122+
and it's likely not going to yield satisfying results.
123+
124+
Partition addressing is designed as a routing capability that consistently assigns events from the same sources to the same partition allowing
125+
downstream consumer systems to be optimized, but under the assumption of very many of such sources (hundreds, thousands) share
126+
the same partition. If you need fine-grained content-based routing, Service Bus Topics might be the better option.
127127

128128
#### Using Partition Keys
129129

130130
Of the two addressing options, the preferable one is to let the hash algorithm map the event to the appropriate partition.
131-
The gesture is a straightforward extra override to the send operation supplying the partition key:
131+
The gesture is a straightforward extra override to the send operation supplying the partition key:
132132

133133
```Java
134134
EventData sendEvent = EventData.create(payloadBytes);
135135
> ehClient.sendSync(sendEvent, partitionKey);
136136
```
137-
137+
138138
#### Using Partition Ids
139139

140-
If you indeed need to target a specific partition, for instance because you must use a particular distribution strategy,
140+
If you indeed need to target a specific partition, for instance because you must use a particular distribution strategy,
141141
you can send directly to the partition, but doing so requires an extra gesture so that you don't accidentally choose this
142142
option. To send to a partition you explicitly need to create a client object that is tied to the partition as shown below:
143143

@@ -151,24 +151,24 @@ option. To send to a partition you explicitly need to create a client object tha
151151
#### Publisher Policies
152152

153153
Event Hub Publisher Policies are not yet supported by this client and will be supported in a future release.
154-
154+
155155
#### Special considerations for partitions and publisher policies
156156

157-
Using partitions or publisher policies (which are effectively a special kind of partition key) may impact throughput
158-
and availability of your Event Hub solution.
157+
Using partitions or publisher policies (which are effectively a special kind of partition key) may impact throughput
158+
and availability of your Event Hub solution.
159159

160-
When you do a regular send operation that does not prescribe a particular partition, the Event Hub will choose a
161-
partition at random, ensuring about equal distribution of events across partitions. Sticking with the above analogy,
162-
all highway lanes get the same traffic.
160+
When you do a regular send operation that does not prescribe a particular partition, the Event Hub will choose a
161+
partition at random, ensuring about equal distribution of events across partitions. Sticking with the above analogy,
162+
all highway lanes get the same traffic.
163163

164-
If you explicitly choose the partition key or partition-id, it's up to you to take care that traffic is evenly
165-
distributed, otherwise you may end up with a traffic jam (in the form of throttling) on one partition while there's
166-
little or no traffic on another partition.
164+
If you explicitly choose the partition key or partition-id, it's up to you to take care that traffic is evenly
165+
distributed, otherwise you may end up with a traffic jam (in the form of throttling) on one partition while there's
166+
little or no traffic on another partition.
167167

168-
Also, like every other aspect of distributed systems, the log storage backing any partition may rarely and briefly slow
168+
Also, like every other aspect of distributed systems, the log storage backing any partition may rarely and briefly slow
169169
down or experience congestion. If you leave choosing the target partition for an event to Event Hubs, it can flexibly
170-
react to such availability blips for publishers.
170+
react to such availability blips for publishers.
171171

172-
Generally, you should *not* use partitioning as a traffic prioritization scheme, and you should *not* use it
173-
for fine grained assignment of particular kinds of events to a particular partitions. *Partitions are a load
172+
Generally, you should *not* use partitioning as a traffic prioritization scheme, and you should *not* use it
173+
for fine grained assignment of particular kinds of events to a particular partitions. *Partitions are a load
174174
distribution mechanism, not a filtering model*.

eventhubs/data-plane/azure-eventhubs-eph/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<parent>
88
<groupId>com.microsoft.azure</groupId>
99
<artifactId>azure-eventhubs-clients</artifactId>
10-
<version>2.3.0</version>
10+
<version>2.3.1</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

1414
<modelVersion>4.0.0</modelVersion>
1515
<groupId>com.microsoft.azure</groupId>
1616
<artifactId>azure-eventhubs-eph</artifactId>
17-
<version>2.5.0</version>
17+
<version>2.5.1</version>
1818

1919
<name>Microsoft Azure SDK for Event Hubs Event Processor Host(EPH)</name>
2020
<description>EPH is built on top of the Azure Event Hubs Client and provides a number of features not present in that lower layer</description>

eventhubs/data-plane/azure-eventhubs-extensions/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.microsoft.azure</groupId>
99
<artifactId>azure-eventhubs-clients</artifactId>
10-
<version>2.3.0</version>
10+
<version>2.3.1</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

eventhubs/data-plane/azure-eventhubs/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.microsoft.azure</groupId>
99
<artifactId>azure-eventhubs-clients</artifactId>
10-
<version>2.3.0</version>
10+
<version>2.3.1</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

eventhubs/data-plane/azure-eventhubs/src/main/java/com/microsoft/azure/eventhubs/ConnectionStringBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ private void parseConnectionString(final String connectionString) {
406406
this.transportType = TransportType.fromString(values[valueIndex]);
407407
} catch (IllegalArgumentException exception) {
408408
throw new IllegalConnectionStringFormatException(
409-
String.format("Invalid value specified for property '%s' in the ConnectionString.", TRANSPORT_TYPE_CONFIG_NAME),
409+
String.format(Locale.US, "Invalid value specified for property '%s' in the ConnectionString.", TRANSPORT_TYPE_CONFIG_NAME),
410410
exception);
411411
}
412412
} else {

eventhubs/data-plane/azure-eventhubs/src/main/java/com/microsoft/azure/eventhubs/impl/ClientConstants.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public final class ClientConstants {
3737
public static final String NO_RETRY = "NoRetry";
3838
public static final String DEFAULT_RETRY = "Default";
3939
public static final String PRODUCT_NAME = "MSJavaClient";
40-
public static final String CURRENT_JAVACLIENT_VERSION = "2.3.0";
40+
public static final String CURRENT_JAVACLIENT_VERSION = "2.3.1";
4141
public static final String PLATFORM_INFO = getPlatformInfo();
4242
public static final String FRAMEWORK_INFO = getFrameworkInfo();
4343
public static final String CBS_ADDRESS = "$cbs";

eventhubs/data-plane/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<groupId>com.microsoft.azure</groupId>
1616
<artifactId>azure-eventhubs-clients</artifactId>
1717
<packaging>pom</packaging>
18-
<version>2.3.0</version>
18+
<version>2.3.1</version>
1919

2020
<name>Microsoft Azure Event Hubs SDK Parent</name>
2121
<description>Java libraries for talking to Windows Azure Event Hubs</description>

0 commit comments

Comments
 (0)