Skip to content

Commit d4f02c5

Browse files
authored
EventHubs: Adding retry for create-batch api (Azure#32751)
1 parent ce29be9 commit d4f02c5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Bugs Fixed
1212

13+
- Added retry for createBatch API as this API also makes network calls similar to its companion send API.
14+
1315
### Other Changes
1416

1517
## 5.15.0 (2022-11-16)

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public Mono<EventDataBatch> createBatch(CreateBatchOptions options) {
306306
MAX_PARTITION_KEY_LENGTH)));
307307
}
308308

309-
return getSendLink(partitionId)
309+
final Mono<EventDataBatch> createBatch = getSendLink(partitionId)
310310
.flatMap(link -> link.getLinkSize()
311311
.flatMap(size -> {
312312
final int maximumLinkSize = size > 0
@@ -326,6 +326,12 @@ public Mono<EventDataBatch> createBatch(CreateBatchOptions options) {
326326

327327
return Mono.just(new EventDataBatch(batchSize, partitionId, partitionKey, link::getErrorContext, instrumentation));
328328
}));
329+
330+
// Similar to the companion API 'send', the 'create-batch' can also make network calls, so retry in case
331+
// of transient errors.
332+
return withRetry(createBatch, retryOptions,
333+
String.format("partitionId[%s]: Creating batch timed out.", partitionId))
334+
.publishOn(scheduler);
329335
}
330336

331337
/**

0 commit comments

Comments
 (0)