Skip to content

Commit

Permalink
Update Java samples for 3.0.0 client (#455)
Browse files Browse the repository at this point in the history
* Update client version in poms to 3.0.0

* Remove unwanted files

* Update API names
  • Loading branch information
JamesBirdsall authored and serkantkaraca committed Oct 18, 2024
1 parent bfcc00d commit 1a9a540
Show file tree
Hide file tree
Showing 22 changed files with 86 additions and 139 deletions.
14 changes: 7 additions & 7 deletions samples/Java/Basic/AdvancedSendOptions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
</dependencies>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void main(String[] args)

// Each EventHubClient instance spins up a new TCP/SSL connection, which is expensive.
// It is always a best practice to reuse these instances. The following sample shows the same.
final EventHubClient ehClient = EventHubClient.createSync(connStr.toString(), executorService);
final EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString(), executorService);
PartitionSender sender = null;

try {
Expand Down
28 changes: 0 additions & 28 deletions samples/Java/Basic/EventProcessorSample/.classpath

This file was deleted.

23 changes: 0 additions & 23 deletions samples/Java/Basic/EventProcessorSample/.project

This file was deleted.

32 changes: 16 additions & 16 deletions samples/Java/Basic/EventProcessorSample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,26 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs-eph</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs-eph</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ public static void main(String args[]) throws InterruptedException, ExecutionExc
// Create the instance of EventProcessorHost using the most basic constructor. This constructor uses Azure Storage for
// persisting partition leases and checkpoints. The host name, which identifies the instance of EventProcessorHost, must be unique.
// You can use a plain UUID, or use the createHostName utility method which appends a UUID to a supplied string.
EventProcessorHost host = new EventProcessorHost(
EventProcessorHost.createHostName(hostNamePrefix),
eventHubName,
consumerGroupName,
eventHubConnectionString.toString(),
storageConnectionString,
storageContainerName);
EventProcessorHost host = EventProcessorHost.EventProcessorHostBuilder
.newBuilder(EventProcessorHost.createHostName(hostNamePrefix), consumerGroupName)
.useAzureStorageCheckpointLeaseManager(storageConnectionString, storageContainerName, null)
.useEventHubConnectionString(eventHubConnectionString.toString(), eventHubName)
.build();

// Registering an event processor class with an instance of EventProcessorHost starts event processing. The host instance
// obtains leases on some partitions of the Event Hub, possibly stealing some from other host instances, in a way that
Expand Down
12 changes: 6 additions & 6 deletions samples/Java/Basic/ReceiveByDateTime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void main(String[] args)
.setSasKey("---SharedAccessSignatureKey----");

final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(4);
final EventHubClient ehClient = EventHubClient.createSync(connStr.toString(), executorService);
final EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString(), executorService);

final EventHubRuntimeInformation eventHubInfo = ehClient.getRuntimeInformation().get();
final String partitionId = eventHubInfo.getPartitionIds()[0]; // get first partition's id
Expand Down
12 changes: 6 additions & 6 deletions samples/Java/Basic/ReceiveUsingOffset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void main(String[] args)
.setSasKey("---SharedAccessSignatureKey----");

final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(4);
final EventHubClient ehClient = EventHubClient.createSync(connStr.toString(), executorService);
final EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString(), executorService);

final EventHubRuntimeInformation eventHubInfo = ehClient.getRuntimeInformation().get();
final String partitionId = eventHubInfo.getPartitionIds()[0]; // get first partition's id
Expand Down
12 changes: 6 additions & 6 deletions samples/Java/Basic/ReceiveUsingSequenceNumber/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void main(String[] args)
.setSasKey("---SharedAccessSignatureKey----");

final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(4);
final EventHubClient ehClient = EventHubClient.createSync(connStr.toString(), executorService);
final EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString(), executorService);

final EventHubRuntimeInformation eventHubInfo = ehClient.getRuntimeInformation().get();
final String partitionId = eventHubInfo.getPartitionIds()[0]; // get first partition's id
Expand Down
14 changes: 7 additions & 7 deletions samples/Java/Basic/SendBatch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>[2.8.2,]</version>
</dependency>
</dependencies>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void main(String[] args)

final Gson gson = new GsonBuilder().create();
final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(4);
final EventHubClient sender = EventHubClient.createSync(connStr.toString(), executorService);
final EventHubClient sender = EventHubClient.createFromConnectionStringSync(connStr.toString(), executorService);

try {
for (int batchNumber = 0; batchNumber < 10; batchNumber++) {
Expand Down
10 changes: 5 additions & 5 deletions samples/Java/Basic/SimpleProxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected PasswordAuthentication getPasswordAuthentication() {
connStr.setTransportType(TransportType.AMQP_WEB_SOCKETS);

final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(4);
final EventHubClient ehClient = EventHubClient.createSync(connStr.toString(), executorService);
final EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString(), executorService);
final Gson gson = new GsonBuilder().create();
PartitionSender sender = null;

Expand Down
14 changes: 7 additions & 7 deletions samples/Java/Basic/SimpleSend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
</dependencies>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void main(String[] args)

// Each EventHubClient instance spins up a new TCP/SSL connection, which is expensive.
// It is always a best practice to reuse these instances. The following sample shows this.
final EventHubClient ehClient = EventHubClient.createSync(connStr.toString(), executorService);
final EventHubClient ehClient = EventHubClient.createFromConnectionStringSync(connStr.toString(), executorService);

try {
for (int i = 0; i < 100; i++) {
Expand Down
12 changes: 6 additions & 6 deletions samples/Java/Benchmarks/AutoScaleOnIngress/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public CompletableFuture<Void> initialize() throws IOException, EventHubExceptio
final CompletableFuture[] createSenders = new CompletableFuture[this.poolSize];
for (int count = 0; count < poolSize; count++) {
final int clientsIndex = count;
createSenders[count] = EventHubClient.create(this.connectionString, executorService).thenAccept(new Consumer<EventHubClient>() {
createSenders[count] = EventHubClient.createFromConnectionString(this.connectionString, executorService).thenAccept(new Consumer<EventHubClient>() {
@Override
public void accept(EventHubClient eventHubClient) {
clients[clientsIndex] = eventHubClient;
Expand Down
12 changes: 6 additions & 6 deletions samples/Java/Benchmarks/IngressBenchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public CompletableFuture<Void> initialize() throws IOException, EventHubExceptio
final CompletableFuture[] createSenders = new CompletableFuture[this.poolSize];
for (int count = 0; count < poolSize; count++) {
final int clientsIndex = count;
createSenders[count] = EventHubClient.create(this.connectionString, executorService).thenAccept(new Consumer<EventHubClient>() {
createSenders[count] = EventHubClient.createFromConnectionString(this.connectionString, executorService).thenAccept(new Consumer<EventHubClient>() {
@Override
public void accept(EventHubClient eventHubClient) {
clients[clientsIndex] = eventHubClient;
Expand Down

0 comments on commit 1a9a540

Please sign in to comment.