Skip to content

Commit 9af9002

Browse files
authored
Updating service bus and event hubs java docs (Azure#18426)
* Replace README with renderable links. * Fix format strings. * Update EventBatchContext and EventHubClientBuilder docs
1 parent 03ea997 commit 9af9002

File tree

12 files changed

+214
-93
lines changed

12 files changed

+214
-93
lines changed

sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ documentation][event_hubs_product_docs] | [Samples][sample_examples]
1414
- A [Java Development Kit (JDK)][jdk_link], version 8 or later.
1515
- [Maven][maven]
1616
- Microsoft Azure subscription
17-
- You can create a free account at: https://azure.microsoft.com
17+
- You can create a free account at: [https://azure.microsoft.com](https://azure.microsoft.com)
1818
- Azure Event Hubs instance
1919
- Step-by-step guide for [creating an Event Hub using the Azure Portal][event_hubs_create]
2020
- Azure Storage account
@@ -81,8 +81,8 @@ BlobContainerAsyncClient blobContainerAsyncClient = new BlobContainerClientBuild
8181

8282
### Consume events using an Event Processor Client
8383

84-
To consume events for all partitions of an Event Hub, you'll create an
85-
[`EventProcessorClient`][source_eventprocessorclient] for a specific consumer group. When an Event Hub is created, it
84+
To consume events for all partitions of an Event Hub, you'll create an
85+
[`EventProcessorClient`][source_eventprocessorclient] for a specific consumer group. When an Event Hub is created, it
8686
provides a default consumer group that can be used to get started.
8787

8888
The [`EventProcessorClient`][source_eventprocessorclient] will delegate processing of events to a callback function that you

sdk/eventhubs/azure-messaging-eventhubs/README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,23 @@ documentation][event_hubs_product_docs] | [Samples][sample_examples]
2121

2222
## Table of contents
2323

24-
- [Table of contents](#table-of-contents)
25-
- [Getting started](#getting-started)
26-
- [Prerequisites](#prerequisites)
27-
- [Include the package](#include-the-package)
28-
- [Authenticate the client](#authenticate-the-client)
29-
- [Create an Event Hub producer using a connection string](#create-an-event-hub-producer-using-a-connection-string)
30-
- [Create an Event Hub client using Microsoft identity platform (formerly Azure Active Directory)](#create-an-event-hub-client-using-microsoft-identity-platform-formerly-azure-active-directory)
31-
- [Key concepts](#key-concepts)
32-
- [Examples](#examples)
33-
- [Publish events to an Event Hub](#publish-events-to-an-event-hub)
34-
- [Consume events from an Event Hub partition](#consume-events-from-an-event-hub-partition)
35-
- [Consume events using an EventProcessorClient](#consume-events-using-an-eventprocessorclient)
36-
- [Troubleshooting](#troubleshooting)
37-
- [Enable client logging](#enable-client-logging)
38-
- [Enable AMQP transport logging](#enable-amqp-transport-logging)
39-
- [Exceptions](#exceptions)
40-
- [Next steps](#next-steps)
41-
- [Contributing](#contributing)
24+
- [Azure Event Hubs client library for Java](#azure-event-hubs-client-library-for-java)
25+
- [Table of contents](#table-of-contents)
26+
- [Getting started](#getting-started)
27+
- [Prerequisites](#prerequisites)
28+
- [Include the package](#include-the-package)
29+
- [Authenticate the client](#authenticate-the-client)
30+
- [Key concepts](#key-concepts)
31+
- [Examples](#examples)
32+
- [Publish events to an Event Hub](#publish-events-to-an-event-hub)
33+
- [Consume events from an Event Hub partition](#consume-events-from-an-event-hub-partition)
34+
- [Consume events using an EventProcessorClient](#consume-events-using-an-eventprocessorclient)
35+
- [Troubleshooting](#troubleshooting)
36+
- [Enable client logging](#enable-client-logging)
37+
- [Enable AMQP transport logging](#enable-amqp-transport-logging)
38+
- [Exceptions](#exceptions)
39+
- [Next steps](#next-steps)
40+
- [Contributing](#contributing)
4241

4342
## Getting started
4443

@@ -47,7 +46,7 @@ documentation][event_hubs_product_docs] | [Samples][sample_examples]
4746
- A [Java Development Kit (JDK)][jdk_link], version 8 or later.
4847
- [Maven][maven]
4948
- Microsoft Azure subscription
50-
- You can create a free account at: https://azure.microsoft.com
49+
- You can create a free account at: [https://azure.microsoft.com](https://azure.microsoft.com)
5150
- Azure Event Hubs instance
5251
- Step-by-step guide for [creating an Event Hub using the Azure Portal][event_hubs_create]
5352

@@ -75,7 +74,7 @@ namespace. If you aren't familiar with shared access policies in Azure, you may
7574
[get an Event Hubs connection string][event_hubs_connection_string].
7675

7776
Both the asynchronous and synchronous Event Hub producer and consumer clients can be created using
78-
`EventHubClientBuilder`. Invoking `build*Client()` creates a synchronous producer or consumer while
77+
`EventHubClientBuilder`. Invoking `build*Client()` creates a synchronous producer or consumer while
7978
`build*AsyncClient()` creates its asynchronous counterpart.
8079

8180
The snippet below creates a synchronous Event Hub producer.
@@ -166,7 +165,7 @@ distributed evenly among the partitions.
166165

167166
#### Create an Event Hub producer and publish events
168167

169-
Developers can create a producer using `EventHubClientBuilder` and calling `buildProducer*Client()`. Specifying
168+
Developers can create a producer using `EventHubClientBuilder` and calling `buildProducer*Client()`. Specifying
170169
`CreateBatchOptions.setPartitionId(String)` will send events to a specific partition. If `partitionId` is not specified,
171170
events are automatically routed to a partition. Specifying `CreateBatchOptions.setPartitionKey(String)` will tell Event
172171
Hubs service to hash the events and send them to the same partition.
@@ -203,7 +202,7 @@ if (eventDataBatch.getCount() > 0) {
203202

204203
#### Publish events using partition identifier
205204

206-
Many Event Hub operations take place within the scope of a specific partition. Any client can call
205+
Many Event Hub operations take place within the scope of a specific partition. Any client can call
207206
`getPartitionIds()` or `getEventHubProperties()` to get the partition ids and metadata about in their Event Hub
208207
instance.
209208

@@ -386,7 +385,7 @@ The recommended way to solve the specific exception the AMQP exception represent
386385
## Next steps
387386

388387
Beyond those discussed, the Azure Event Hubs client library offers support for many other scenarios to take
389-
advantage of the full feature set of the Azure Event Hubs service. To explore some of these scenarios, check out the
388+
advantage of the full feature set of the Azure Event Hubs service. To explore some of these scenarios, check out the
390389
[samples README][samples_readme].
391390

392391
## Contributing
@@ -409,7 +408,7 @@ Guidelines](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/eventhub
409408
[event_hubs_connection_string]: https://docs.microsoft.com/azure/event-hubs/event-hubs-get-connection-string
410409
[event_hubs_create]: https://docs.microsoft.com/azure/event-hubs/event-hubs-create
411410
[event_hubs_features]: https://docs.microsoft.com/azure/event-hubs/event-hubs-features
412-
[event_hubs_messaging_exceptions]: https://docs.microsoft.com/azure/event-hubs/event-hubs-messaging-exceptions
411+
[event_hubs_messaging_exceptions]: https://docs.microsoft.com/azure/event-hubs/event-hubs-messaging-exceptions
413412
[event_hubs_product_docs]: https://docs.microsoft.com/azure/event-hubs/
414413
[event_hubs_quotas]: https://docs.microsoft.com/azure/event-hubs/event-hubs-quotas
415414
[EventHubConsumerAsyncClient]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerAsyncClient.java

sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/CheckpointStore.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
/**
1313
* An interface that defines the operations for storing and retrieving partition ownership information and checkpoint
1414
* details for each partition.
15+
*
16+
* @see EventProcessorClientBuilder#checkpointStore(CheckpointStore)
1517
*/
1618
public interface CheckpointStore {
1719

@@ -23,7 +25,7 @@ public interface CheckpointStore {
2325
* <strong>{@literal "{your-namespace}.servicebus.windows.net}"</strong>.
2426
* @param eventHubName The Event Hub name to get ownership information.
2527
* @param consumerGroup The consumer group name.
26-
* @return A flux of partition ownership details of all the partitions that have/had an owner.
28+
* @return A {@link Flux} of partition ownership details of all the partitions that have/had an owner.
2729
*/
2830
Flux<PartitionOwnership> listOwnership(String fullyQualifiedNamespace, String eventHubName,
2931
String consumerGroup);
@@ -33,7 +35,7 @@ Flux<PartitionOwnership> listOwnership(String fullyQualifiedNamespace, String ev
3335
* successfully.
3436
*
3537
* @param requestedPartitionOwnerships List of partition ownerships this instance is requesting to own.
36-
* @return A flux of partitions this instance successfully claimed ownership.
38+
* @return A {@link Flux} of partitions this instance successfully claimed ownership.
3739
*/
3840
Flux<PartitionOwnership> claimOwnership(List<PartitionOwnership> requestedPartitionOwnerships);
3941

@@ -44,7 +46,7 @@ Flux<PartitionOwnership> listOwnership(String fullyQualifiedNamespace, String ev
4446
* @param fullyQualifiedNamespace The fully qualified namespace of the Event Hub.
4547
* @param eventHubName The Event Hub name to get checkpoint information.
4648
* @param consumerGroup The consumer group name associated with the checkpoint.
47-
* @return A flux of checkpoints associated with the partitions of the Event Hub.
49+
* @return A {@link Flux} of checkpoints associated with the partitions of the Event Hub.
4850
*/
4951
Flux<Checkpoint> listCheckpoints(String fullyQualifiedNamespace, String eventHubName, String consumerGroup);
5052

sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventDataBatch.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.azure.core.util.Context;
1313
import com.azure.core.util.logging.ClientLogger;
1414
import com.azure.core.util.tracing.ProcessKind;
15+
import com.azure.messaging.eventhubs.models.CreateBatchOptions;
1516
import org.apache.qpid.proton.Proton;
1617
import org.apache.qpid.proton.amqp.Binary;
1718
import org.apache.qpid.proton.amqp.Symbol;
@@ -42,7 +43,9 @@
4243
* sent to the Azure Event Hubs service.
4344
*
4445
* @see EventHubProducerClient#createBatch()
46+
* @see EventHubProducerClient#createBatch(CreateBatchOptions)
4547
* @see EventHubProducerAsyncClient#createBatch()
48+
* @see EventHubProducerAsyncClient#createBatch(CreateBatchOptions)
4649
* @see EventHubClientBuilder See EventHubClientBuilder for examples of building an asynchronous or synchronous
4750
* producer.
4851
*/

sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubClientBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
* </ul>
6666
*
6767
* <p>
68-
* In addition, <strong>consumer group</strong> is required when creating {@link EventHubConsumerAsyncClient} or
68+
* In addition, the <strong>consumer group</strong> is required when creating {@link EventHubConsumerAsyncClient} or
6969
* {@link EventHubConsumerClient}.
7070
* </p>
7171
*

sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubConsumerClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
*
3131
* <p><strong>Consuming events from a single partition</strong></p>
3232
* <p>Events from a single partition can be consumed using {@link #receiveFromPartition(String, int, EventPosition)} or
33-
* {@link #receiveFromPartition(String, int, EventPosition, Duration)}. The call to `receive` completes and returns an
34-
* {@link IterableStream} when either the maximum number of events is received, or the timeout has elapsed.</p>
33+
* {@link #receiveFromPartition(String, int, EventPosition, Duration)}. The call to {@code receiveFromPartition}
34+
* completes and returns an {@link IterableStream} when either the maximum number of events is received, or the
35+
* timeout has elapsed.</p>
3536
*
3637
* {@codesnippet com.azure.messaging.eventhubs.eventhubconsumerclient.receive#string-int-eventposition-duration}
3738
*/

sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventProcessorClientBuilder.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,18 @@
4545
* from the Event Hub.</li>
4646
* <li>{@link #processError(Consumer) processError} - A callback that handles errors that may occur while running the
4747
* EventProcessorClient.</li>
48-
* <li>Credentials -
49-
* <strong>Credentials are required</strong> to perform operations against Azure Event Hubs. They can be set by using
50-
* one of the following methods:
51-
* <ul>
52-
* <li>{@link #connectionString(String)} with a connection string to a specific Event Hub.
53-
* </li>
54-
* <li>{@link #connectionString(String, String)} with an Event Hub <i>namespace</i> connection string and the Event Hub
55-
* name.</li>
56-
* <li>{@link #credential(String, String, TokenCredential)} with the fully qualified namespace, Event Hub name, and a
57-
* set of credentials authorized to use the Event Hub.
58-
* </li>
59-
* </ul>
60-
* </li>
48+
* <li>Credentials to perform operations against Azure Event Hubs. They can be set by using one of the following
49+
* methods:
50+
* <ul>
51+
* <li>{@link #connectionString(String) connectionString(String)} with a connection string to a specific Event Hub.
52+
* </li>
53+
* <li>{@link #connectionString(String, String) connectionString(String, String)} with an Event Hub <i>namespace</i>
54+
* connection string and the Event Hub name.</li>
55+
* <li>{@link #credential(String, String, TokenCredential) credential(String, String, TokenCredential)} with the fully
56+
* qualified namespace, Event Hub name, and a set of credentials authorized to use the Event Hub.
57+
* </li>
58+
* </ul>
59+
* </li>
6160
* </ul>
6261
*
6362
* <p><strong>Creating an {@link EventProcessorClient}</strong></p>

sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/LoadBalancingStrategy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
/**
77
* The strategy used by event processor for load balancing the partition ownership to distribute the event processing
88
* work with other processor instances.
9+
*
10+
* @see EventProcessorClientBuilder#loadBalancingStrategy(LoadBalancingStrategy)
911
*/
1012
public enum LoadBalancingStrategy {
1113

sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/models/EventBatchContext.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33

44
package com.azure.messaging.eventhubs.models;
55

6+
import com.azure.core.amqp.exception.AmqpException;
67
import com.azure.messaging.eventhubs.CheckpointStore;
78
import com.azure.messaging.eventhubs.EventData;
89
import com.azure.messaging.eventhubs.EventProcessorClientBuilder;
10+
11+
import java.time.Duration;
912
import java.util.List;
13+
import java.util.Objects;
1014
import java.util.function.Consumer;
1115
import reactor.core.publisher.Mono;
1216

@@ -15,6 +19,9 @@
1519
* given to the {@link EventProcessorClientBuilder#processEventBatch(Consumer, int) processEventBatch} handler each
1620
* time an event batch is received from the Event Hub. This class also includes methods to update checkpoint in
1721
* {@link CheckpointStore} and retrieve the last enqueued event information.
22+
*
23+
* @see EventProcessorClientBuilder#processEventBatch(Consumer, int)
24+
* @see EventProcessorClientBuilder#processEventBatch(Consumer, int, Duration)
1825
*/
1926
public class EventBatchContext {
2027

@@ -36,10 +43,11 @@ public class EventBatchContext {
3643
*/
3744
public EventBatchContext(PartitionContext partitionContext, List<EventData> events,
3845
CheckpointStore checkpointStore, LastEnqueuedEventProperties lastEnqueuedEventProperties) {
39-
this.checkpointStore = checkpointStore;
40-
this.events = events;
46+
this.checkpointStore = Objects.requireNonNull(checkpointStore, "'checkpointStore' cannot be null.");
47+
this.events = Objects.requireNonNull(events, "'events' cannot be null.");
48+
this.partitionContext = Objects.requireNonNull(partitionContext, "'partitionContext' cannot be null.");
49+
4150
this.lastEnqueuedEventProperties = lastEnqueuedEventProperties;
42-
this.partitionContext = partitionContext;
4351
}
4452

4553
/**
@@ -79,12 +87,14 @@ public LastEnqueuedEventProperties getLastEnqueuedEventProperties() {
7987
* if the update is successful. If {@link #getEvents()} returns an empty, no update to checkpoint will be
8088
* done.
8189
*
82-
* @return a representation of deferred execution of this call.
90+
* @return Gets a {@link Mono} that completes when the checkpoint is updated.
91+
* @throws AmqpException if an error occurs when updating the checkpoint.
8392
*/
8493
public Mono<Void> updateCheckpointAsync() {
85-
if (this.events == null || this.events.isEmpty()) {
94+
if (this.events.isEmpty()) {
8695
return Mono.empty();
8796
}
97+
8898
// update checkpoint of the last event in the batch
8999
Checkpoint checkpoint = new Checkpoint()
90100
.setFullyQualifiedNamespace(partitionContext.getFullyQualifiedNamespace())
@@ -101,6 +111,8 @@ public Mono<Void> updateCheckpointAsync() {
101111
* {@link #getEvents()}. This will serve as the last known successfully processed event in this partition
102112
* if the update is successful. If {@link #getEvents()} returns an empty, no update to checkpoint will be
103113
* done.
114+
*
115+
* @throws AmqpException if an error occurs while updating the checkpoint.
104116
*/
105117
public void updateCheckpoint() {
106118
this.updateCheckpointAsync().block();

0 commit comments

Comments
 (0)