This commit is contained in:
azure-sdk 2024-05-22 19:18:31 +00:00
Родитель 64b843591d
Коммит 7611d92cb1
6 изменённых файлов: 171 добавлений и 116 удалений

Просмотреть файл

@ -1,12 +1,12 @@
---
title: Azure Event Hubs Checkpoint Store client library for Java
keywords: Azure, java, SDK, API, azure-messaging-eventhubs-checkpointstore-blob, eventhubs
ms.date: 02/01/2023
keywords: Azure, java, SDK, API, azure-messaging-eventhubs-checkpointstore-blob, event-hubs
ms.date: 05/22/2024
ms.topic: reference
ms.devlang: java
ms.service: eventhubs
ms.service: event-hubs
---
# Azure Event Hubs Checkpoint Store client library for Java - version 1.17.0-beta.1
# Azure Event Hubs Checkpoint Store client library for Java - version 1.20.0-beta.1
using Storage Blobs
Azure Event Hubs Checkpoint Store can be used for storing checkpoints while processing events from Azure Event Hubs.
@ -33,7 +33,7 @@ documentation][event_hubs_product_docs] | [Samples][sample_examples]
#### Include the BOM file
Please include the azure-sdk-bom to your project to take dependency on the General Availability (GA) version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number.
To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/boms/azure-sdk-bom/README.md).
To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/boms/azure-sdk-bom/README.md).
```xml
<dependencyManagement>
@ -68,7 +68,7 @@ add the direct dependency to your project as follows.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventhubs-checkpointstore-blob</artifactId>
<version>1.17.0-beta.1</version>
<version>1.20.0-beta.1</version>
</dependency>
```
[//]: # ({x-version-update-end})
@ -185,7 +185,7 @@ Get started by exploring the samples [here][samples_readme].
## Contributing
If you would like to become an active contributor to this project please refer to our [Contribution
Guidelines](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/CONTRIBUTING.md) for more information.
Guidelines](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/CONTRIBUTING.md) for more information.
<!-- Links -->
[api_documentation]: https://azure.github.io/azure-sdk-for-java
@ -196,18 +196,18 @@ Guidelines](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eve
[logging]: https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK
[maven]: https://maven.apache.org/
[performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning
[samples_readme]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/README.md
[sample_azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/EventProcessorWithAzureIdentity.java
[sample_container_client]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStoreSample.java
[sample_event_hubs]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs
[sample_event_processor]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/EventProcessorBlobCheckpointStoreSample.java
[sample_checkpointstore_custom_storage_version]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/EventProcessorWithCustomStorageVersion.java
[sample_examples]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob
[samples_readme]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/README.md
[sample_azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/EventProcessorWithAzureIdentity.java
[sample_container_client]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStoreSample.java
[sample_event_hubs]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs
[sample_event_processor]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/EventProcessorBlobCheckpointStoreSample.java
[sample_checkpointstore_custom_storage_version]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob/EventProcessorWithCustomStorageVersion.java
[sample_examples]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/blob
[sas_token]: /azure/storage/common/storage-dotnet-shared-access-signature-part-1
[source_code]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/
[source_eventprocessorclient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClient.java
[source_blobcheckpointstore]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/main/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStore.java
[source_loglevels]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/.https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.17.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
[source_code]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/
[source_eventprocessorclient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClient.java
[source_blobcheckpointstore]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/main/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStore.java
[source_loglevels]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/.https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-blob_1.20.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
[storage_account]: /azure/storage/common/storage-quickstart-create-account?tabs=azure-portal
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Feventhubs%2Fazure-messaging-eventhubs-checkpointstore-blob%2FREADME.png)

Просмотреть файл

@ -1,12 +1,12 @@
---
title: Azure Event Hubs Checkpoint Store client library for Java
keywords: Azure, java, SDK, API, azure-messaging-eventhubs-checkpointstore-jedis, eventhubs
ms.date: 09/25/2023
keywords: Azure, java, SDK, API, azure-messaging-eventhubs-checkpointstore-jedis, event-hubs
ms.date: 05/22/2024
ms.topic: reference
ms.devlang: java
ms.service: eventhubs
ms.service: event-hubs
---
# Azure Event Hubs Checkpoint Store client library for Java - version 1.0.0-beta.2
# Azure Event Hubs Checkpoint Store client library for Java - version 1.0.0-beta.3
using the Jedis Client Library for Redis
Azure Event Hubs Checkpoint Store can be used for storing checkpoints while processing events from Azure Event Hubs.
@ -33,7 +33,7 @@ documentation][event_hubs_product_docs] | [Samples][sample_examples]
#### Include the BOM file
Please include the azure-sdk-bom to your project to take dependency on the General Availability (GA) version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number.
To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/boms/azure-sdk-bom/README.md).
To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/boms/azure-sdk-bom/README.md).
```xml
<dependencyManagement>
@ -68,7 +68,7 @@ add the direct dependency to your project as follows.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventhubs-checkpointstore-jedis</artifactId>
<version>1.0.0-beta.2</version>
<version>1.0.0-beta.3</version>
</dependency>
```
[//]: # ({x-version-update-end})
@ -183,17 +183,17 @@ Guidelines][guidelines] for more information.
[event_hubs_create]: /azure/event-hubs/event-hubs-create
[event_hubs_product_docs]: /azure/event-hubs/
[jdk_link]: /java/azure/jdk/?view=azure-java-stable
[key_concepts]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/README.md#key-concepts
[key_concepts]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/README.md#key-concepts
[logging]: https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK
[maven]: https://maven.apache.org/
[redis_quickstart]: https://learn.microsoft.com/azure/azure-cache-for-redis/quickstart-create-redis
[redis_quickstart_java]: https://learn.microsoft.com/azure/azure-cache-for-redis/cache-java-get-started
[samples_readme]: https://github.com/Azure/azure-sdk-for-java/tree/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis
[sample_jedis_client]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/jedis/JedisCheckpointStoreSample.java
[sample_event_processor]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/jedis/EventProcessorClientJedisSample.java
[sample_examples]: https://github.com/Azure/azure-sdk-for-java/tree/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/src/samples
[source_code]: https://github.com/Azure/azure-sdk-for-java/tree/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis
[source_eventprocessorclient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClient.java
[source_jedisredischeckpointstore]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/src/main/java/com/azure/messaging/eventhubs/checkpointstore/jedis/JedisCheckpointStore.java
[guidelines]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.2/CONTRIBUTING.md
[samples_readme]: https://github.com/Azure/azure-sdk-for-java/tree/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis
[sample_jedis_client]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/jedis/JedisCheckpointStoreSample.java
[sample_event_processor]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/src/samples/java/com/azure/messaging/eventhubs/checkpointstore/jedis/EventProcessorClientJedisSample.java
[sample_examples]: https://github.com/Azure/azure-sdk-for-java/tree/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/src/samples
[source_code]: https://github.com/Azure/azure-sdk-for-java/tree/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis
[source_eventprocessorclient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClient.java
[source_jedisredischeckpointstore]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis/src/main/java/com/azure/messaging/eventhubs/checkpointstore/jedis/JedisCheckpointStore.java
[guidelines]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs-checkpointstore-jedis_1.0.0-beta.3/CONTRIBUTING.md

Просмотреть файл

@ -1,12 +1,12 @@
---
title: Azure Event Hubs client library for Java
keywords: Azure, java, SDK, API, azure-messaging-eventhubs, event-hubs
ms.date: 02/01/2023
ms.date: 05/22/2024
ms.topic: reference
ms.devlang: java
ms.service: event-hubs
---
# Azure Event Hubs client library for Java - version 5.16.0-beta.1
# Azure Event Hubs client library for Java - version 5.19.0-beta.1
Azure Event Hubs is a highly scalable publish-subscribe service that can ingest millions of events per second and stream
@ -68,7 +68,7 @@ documentation][event_hubs_product_docs] | [Samples][sample_examples] | [Troubles
#### Include the BOM file
Please include the azure-sdk-bom to your project to take dependency on the General Availability (GA) version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number.
To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/boms/azure-sdk-bom/README.md).
To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/boms/azure-sdk-bom/README.md).
```xml
<dependencyManagement>
@ -103,7 +103,7 @@ add the direct dependency to your project as follows.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventhubs</artifactId>
<version>5.16.0-beta.1</version>
<version>5.19.0-beta.1</version>
</dependency>
```
[//]: # ({x-version-update-end})
@ -125,11 +125,14 @@ Both the asynchronous and synchronous Event Hub producer and consumer clients ca
The snippet below creates a synchronous Event Hub producer.
```java readme-sample-createSynchronousEventHubProducer
String connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>";
String eventHubName = "<< NAME OF THE EVENT HUB >>";
```java com.azure.messaging.eventhubs.eventhubproducerclient.construct
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
// "<<fully-qualified-namespace>>" will look similar to "{your-namespace}.servicebus.windows.net"
// "<<event-hub-name>>" will be the name of the Event Hub instance you created inside the Event Hubs namespace.
EventHubProducerClient producer = new EventHubClientBuilder()
.connectionString(connectionString, eventHubName)
.credential("<<fully-qualified-namespace>>", "<<event-hub-name>>",
credential)
.buildProducerClient();
```
@ -143,7 +146,7 @@ platform. First, add the package:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.5.4</version>
<version>1.12.0</version>
</dependency>
```
[//]: # ({x-version-update-end})
@ -158,16 +161,14 @@ Authorization is easiest using [DefaultAzureCredential][wiki_identity]. It finds
running environment. For more information about using Azure Active Directory authorization with Event Hubs, please refer
to [the associated documentation][aad_authorization].
```java readme-sample-useAadAuthorization
TokenCredential credential = new DefaultAzureCredentialBuilder()
.build();
```java com.azure.messaging.eventhubs.eventhubproducerclient.construct
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
// The fully qualified namespace for the Event Hubs instance. This is likely to be similar to:
// {your-namespace}.servicebus.windows.net
String fullyQualifiedNamespace = "my-test-eventhubs.servicebus.windows.net";
String eventHubName = "<< NAME OF THE EVENT HUB >>";
EventHubProducerClient client = new EventHubClientBuilder()
.credential(fullyQualifiedNamespace, eventHubName, credential)
// "<<fully-qualified-namespace>>" will look similar to "{your-namespace}.servicebus.windows.net"
// "<<event-hub-name>>" will be the name of the Event Hub instance you created inside the Event Hubs namespace.
EventHubProducerClient producer = new EventHubClientBuilder()
.credential("<<fully-qualified-namespace>>", "<<event-hub-name>>",
credential)
.buildProducerClient();
```
@ -217,9 +218,12 @@ Hubs service to hash the events and send them to the same partition.
The snippet below creates a synchronous producer and sends events to any partition, allowing Event Hubs service to route
the event to an available partition.
```java readme-sample-publishEvents
```java com.azure.messaging.eventhubs.eventhubproducerclient.createBatch
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
EventHubProducerClient producer = new EventHubClientBuilder()
.connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>")
.credential("<<fully-qualified-namespace>>", "<<event-hub-name>>",
credential)
.buildProducerClient();
List<EventData> allEvents = Arrays.asList(new EventData("Foo"), new EventData("Bar"));
@ -237,10 +241,15 @@ for (EventData eventData : allEvents) {
}
}
}
// send the last batch of remaining events
if (eventDataBatch.getCount() > 0) {
producer.send(eventDataBatch);
}
// Clients are expected to be long-lived objects.
// Dispose of the producer to close any underlying resources when we are finished with it.
producer.close();
```
Note that `EventDataBatch.tryAdd(EventData)` is not thread-safe. Please make sure to synchronize the method access
when using multiple threads to add events.
@ -251,11 +260,15 @@ Many Event Hub operations take place within the scope of a specific partition. A
`getPartitionIds()` or `getEventHubProperties()` to get the partition ids and metadata about in their Event Hub
instance.
```java readme-sample-publishEventsToPartition
```java com.azure.messaging.eventhubs.eventhubproducerclient.createBatch#CreateBatchOptions-partitionId
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
EventHubProducerClient producer = new EventHubClientBuilder()
.connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>")
.credential("<<fully-qualified-namespace>>", "<<event-hub-name>>",
credential)
.buildProducerClient();
// Creating a batch with partitionId set will route all events in that batch to partition `0`.
CreateBatchOptions options = new CreateBatchOptions().setPartitionId("0");
EventDataBatch batch = producer.createBatch(options);
@ -267,18 +280,21 @@ producer.send(batch);
When a set of events are not associated with any specific partition, it may be desirable to request that the Event
Hubs service keep different events or batches of events together on the same partition. This can be accomplished by
setting a `partition key` when publishing the events.
setting a `partition key` when publishing the events. In the scenario below, all the events are related to cities, so they are sent with the partition key set to "cities".
```java com.azure.messaging.eventhubs.eventhubproducerclient.send#Iterable-SendOptions
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
```java readme-sample-publishEventsWithPartitionKey
EventHubProducerClient producer = new EventHubClientBuilder()
.connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>")
.credential("<<fully-qualified-namespace>>", "<<event-hub-name>>",
credential)
.buildProducerClient();
CreateBatchOptions batchOptions = new CreateBatchOptions().setPartitionKey("grouping-key");
EventDataBatch eventDataBatch = producer.createBatch(batchOptions);
List<EventData> events = Arrays.asList(new EventData("Melbourne"), new EventData("London"),
new EventData("New York"));
// Add events to batch and when you want to send the batch, send it using the producer.
producer.send(eventDataBatch);
SendOptions sendOptions = new SendOptions().setPartitionKey("cities");
producer.send(events, sendOptions);
```
### Consume events from an Event Hub partition
@ -294,18 +310,37 @@ to the newest events that get pushed to the partition. Developers can begin rece
the same `EventHubConsumerAsyncClient` by calling `receiveFromPartition(String, EventPosition)` with another partition
id.
```java readme-sample-consumeEventsFromPartition
```java com.azure.messaging.eventhubs.eventhubconsumerasyncclient.receive#string-eventposition
EventHubConsumerAsyncClient consumer = new EventHubClientBuilder()
.connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>")
.credential("<<fully-qualified-namespace>>", "<<event-hub-name>>",
new DefaultAzureCredentialBuilder().build())
.consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME)
.buildAsyncConsumerClient();
// Receive newly added events from partition with id "0". EventPosition specifies the position
// within the Event Hub partition to begin consuming events.
consumer.receiveFromPartition("0", EventPosition.latest()).subscribe(event -> {
// Process each event as it arrives.
});
// add sleep or System.in.read() to receive events before exiting the process.
// Obtain partitionId from EventHubConsumerAsyncClient.getPartitionIds()
String partitionId = "0";
EventPosition startingPosition = EventPosition.latest();
// Keep a reference to `subscription`. When the program is finished receiving events, call
// subscription.dispose(). This will stop fetching events from the Event Hub.
//
// NOTE: This is a non-blocking call and will move to the next line of code after setting up the async
// operation. If the program ends after this, or the class is immediately disposed, no events will be
// received.
Disposable subscription = consumer.receiveFromPartition(partitionId, startingPosition)
.subscribe(partitionEvent -> {
PartitionContext partitionContext = partitionEvent.getPartitionContext();
EventData event = partitionEvent.getData();
System.out.printf("Received event from partition '%s'%n", partitionContext.getPartitionId());
System.out.printf("Contents of event as string: '%s'%n", event.getBodyAsString());
}, error -> {
// This is a terminal signal. No more events will be received from the same Flux object.
System.err.print("An error occurred:" + error);
}, () -> {
// This is a terminal signal. No more events will be received from the same Flux object.
System.out.print("Stream has ended.");
});
```
#### Consume events with EventHubConsumerClient
@ -313,19 +348,41 @@ consumer.receiveFromPartition("0", EventPosition.latest()).subscribe(event -> {
Developers can create a synchronous consumer that returns events in batches using an `EventHubConsumerClient`. In the
snippet below, a consumer is created that starts reading events from the beginning of the partition's event stream.
```java readme-sample-consumeEventsFromPartitionUsingSyncClient
```java com.azure.messaging.eventhubs.eventhubconsumerclient.receive#string-int-eventposition-duration
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
// "<<fully-qualified-namespace>>" will look similar to "{your-namespace}.servicebus.windows.net"
// "<<event-hub-name>>" will be the name of the Event Hub instance you created inside the Event Hubs namespace.
EventHubConsumerClient consumer = new EventHubClientBuilder()
.connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>")
.credential("<<fully-qualified-namespace>>", "<<event-hub-name>>",
credential)
.consumerGroup(EventHubClientBuilder.DEFAULT_CONSUMER_GROUP_NAME)
.buildConsumerClient();
String partitionId = "<< EVENT HUB PARTITION ID >>";
Instant twelveHoursAgo = Instant.now().minus(Duration.ofHours(12));
EventPosition startingPosition = EventPosition.fromEnqueuedTime(twelveHoursAgo);
String partitionId = "0";
// Get the first 15 events in the stream, or as many events as can be received within 40 seconds.
IterableStream<PartitionEvent> events = consumer.receiveFromPartition(partitionId, 15,
EventPosition.earliest(), Duration.ofSeconds(40));
for (PartitionEvent event : events) {
System.out.println("Event: " + event.getData().getBodyAsString());
// Reads events from partition '0' and returns the first 100 received or until the 30 seconds has elapsed.
IterableStream<PartitionEvent> events = consumer.receiveFromPartition(partitionId, 100,
startingPosition, Duration.ofSeconds(30));
Long lastSequenceNumber = -1L;
for (PartitionEvent partitionEvent : events) {
// For each event, perform some sort of processing.
System.out.print("Event received: " + partitionEvent.getData().getSequenceNumber());
lastSequenceNumber = partitionEvent.getData().getSequenceNumber();
}
// Figure out what the next EventPosition to receive from is based on last event we processed in the stream.
// If lastSequenceNumber is -1L, then we didn't see any events the first time we fetched events from the
// partition.
if (lastSequenceNumber != -1L) {
EventPosition nextPosition = EventPosition.fromSequenceNumber(lastSequenceNumber, false);
// Gets the next set of events from partition '0' to consume and process.
IterableStream<PartitionEvent> nextEvents = consumer.receiveFromPartition(partitionId, 100,
nextPosition, Duration.ofSeconds(30));
}
```
@ -343,29 +400,27 @@ In our example, we will focus on building the [`EventProcessorClient`][EventProc
received from the Event Hub and writes to console. For production applications, it's recommended to use a durable
store like [Checkpoint Store with Azure Storage Blobs][BlobCheckpointStore].
```java readme-sample-consumeEventsUsingEventProcessor
```java com.azure.messaging.eventhubs.eventprocessorclientbuilder.construct
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
// "<<fully-qualified-namespace>>" will look similar to "{your-namespace}.servicebus.windows.net"
// "<<event-hub-name>>" will be the name of the Event Hub instance you created inside the Event Hubs namespace.
EventProcessorClient eventProcessorClient = new EventProcessorClientBuilder()
.consumerGroup("<< CONSUMER GROUP NAME >>")
.connectionString("<< EVENT HUB CONNECTION STRING >>")
.credential("<<fully-qualified-namespace>>", "<<event-hub-name>>",
credential)
.checkpointStore(new SampleCheckpointStore())
.processEvent(eventContext -> {
System.out.println("Partition id = " + eventContext.getPartitionContext().getPartitionId() + " and "
+ "sequence number of event = " + eventContext.getEventData().getSequenceNumber());
System.out.printf("Partition id = %s and sequence number of event = %s%n",
eventContext.getPartitionContext().getPartitionId(),
eventContext.getEventData().getSequenceNumber());
})
.processError(errorContext -> {
System.out
.println("Error occurred while processing events " + errorContext.getThrowable().getMessage());
System.out.printf("Error occurred in partition processor for partition %s, %s%n",
errorContext.getPartitionContext().getPartitionId(),
errorContext.getThrowable());
})
.buildEventProcessorClient();
// This will start the processor. It will start processing events from all partitions.
eventProcessorClient.start();
// (for demo purposes only - adding sleep to wait for receiving events)
TimeUnit.SECONDS.sleep(2);
// This will stop processing events.
eventProcessorClient.stop();
```
## Troubleshooting
@ -381,32 +436,32 @@ advantage of the full feature set of the Azure Event Hubs service. To explore so
## Contributing
If you would like to become an active contributor to this project please refer to our [Contribution
Guidelines](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/CONTRIBUTING.md) for more information.
Guidelines](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/CONTRIBUTING.md) for more information.
<!-- Links -->
[aad_authorization]: /azure/event-hubs/authorize-access-azure-active-directory
[amqp_transport_error]: https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-amqp-error
[AmqpErrorCondition]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpErrorCondition.java
[AmqpErrorContext]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpErrorContext.java
[AmqpException]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpException.java
[AmqpRetryOptions]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/AmqpRetryOptions.java
[AmqpErrorCondition]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpErrorCondition.java
[AmqpErrorContext]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpErrorContext.java
[AmqpException]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/exception/AmqpException.java
[AmqpRetryOptions]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/AmqpRetryOptions.java
[api_documentation]: https://aka.ms/java-docs
[app_registration_page]: /azure/active-directory/develop/howto-create-service-principal-portal#get-values-for-signing-in
[application_client_secret]: /azure/active-directory/develop/howto-create-service-principal-portal#create-a-new-application-secret
[BlobCheckpointStore]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/README.md
[CreateBatchOptions]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/models/CreateBatchOptions.java
[BlobCheckpointStore]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/README.md
[CreateBatchOptions]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/models/CreateBatchOptions.java
[event_hubs_connection_string]: /azure/event-hubs/event-hubs-get-connection-string
[event_hubs_create]: /azure/event-hubs/event-hubs-create
[event_hubs_features]: /azure/event-hubs/event-hubs-features
[event_hubs_messaging_exceptions]: /azure/event-hubs/event-hubs-messaging-exceptions
[event_hubs_product_docs]: /azure/event-hubs/
[event_hubs_quotas]: /azure/event-hubs/event-hubs-quotas
[EventHubConsumerAsyncClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClient.java
[EventHubConsumerClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerClient.java
[EventHubProducerAsyncClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java
[EventHubProducerClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerClient.java
[EventProcessorClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClient.java
[SampleCheckpointStore]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/SampleCheckpointStore.java
[EventHubConsumerAsyncClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClient.java
[EventHubConsumerClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerClient.java
[EventHubProducerAsyncClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java
[EventHubProducerClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerClient.java
[EventProcessorClient]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClient.java
[SampleCheckpointStore]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/SampleCheckpointStore.java
[java_8_sdk_javadocs]: https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html
[jdk_link]: /java/azure/jdk/?view=azure-java-stable
[logging]: /azure/developer/java/sdk/logging-overview
@ -415,11 +470,11 @@ Guidelines](https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eve
[oasis_amqp_v1]: https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html
[performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning
[qpid_proton_j_apache]: https://qpid.apache.org/proton/
[sample_examples]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/
[samples_readme]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/samples/README.md
[source_code]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/
[sample_examples]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/
[samples_readme]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/src/samples/README.md
[source_code]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/
[wiki_identity]: https://github.com/Azure/azure-sdk-for-java/wiki/Identity-and-Authentication
[troubleshooting]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.16.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/TROUBLESHOOTING.md
[troubleshooting]: https://github.com/Azure/azure-sdk-for-java/blob/azure-messaging-eventhubs_5.19.0-beta.1/sdk/eventhubs/azure-messaging-eventhubs/TROUBLESHOOTING.md
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Feventhubs%2Fazure-messaging-eventhubs%2FREADME.png)

Просмотреть файл

@ -1,6 +1,6 @@
{
"Name": "azure-messaging-eventhubs-checkpointstore-blob",
"Version": "1.17.0-beta.1",
"Version": "1.20.0-beta.1",
"DevVersion": null,
"DirectoryPath": "sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob",
"ServiceDirectory": "eventhubs",
@ -10,7 +10,7 @@
"SdkType": "client",
"IsNewSdk": true,
"ArtifactName": "azure-messaging-eventhubs-checkpointstore-blob",
"ReleaseStatus": "2023-01-31",
"ReleaseStatus": "2024-05-21",
"Namespaces": [
"com.azure.messaging.eventhubs.checkpointstore.blob"
]

Просмотреть файл

@ -1,6 +1,6 @@
{
"Name": "azure-messaging-eventhubs-checkpointstore-jedis",
"Version": "1.0.0-beta.2",
"Version": "1.0.0-beta.3",
"DevVersion": null,
"DirectoryPath": "sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-jedis",
"ServiceDirectory": "eventhubs",
@ -10,7 +10,7 @@
"SdkType": "client",
"IsNewSdk": true,
"ArtifactName": "azure-messaging-eventhubs-checkpointstore-jedis",
"ReleaseStatus": "2023-09-22",
"ReleaseStatus": "2024-05-21",
"Namespaces": [
"com.azure.messaging.eventhubs.checkpointstore.jedis"
]

Просмотреть файл

@ -1,6 +1,6 @@
{
"Name": "azure-messaging-eventhubs",
"Version": "5.16.0-beta.1",
"Version": "5.19.0-beta.1",
"DevVersion": null,
"DirectoryPath": "sdk/eventhubs/azure-messaging-eventhubs",
"ServiceDirectory": "eventhubs",
@ -10,7 +10,7 @@
"SdkType": "client",
"IsNewSdk": true,
"ArtifactName": "azure-messaging-eventhubs",
"ReleaseStatus": "2023-01-31",
"ReleaseStatus": "2024-05-21",
"Namespaces": [
"com.azure.messaging.eventhubs",
"com.azure.messaging.eventhubs.models"