Class BatchOptions
- java.lang.Object
-
- com.microsoft.azure.eventhubs.BatchOptions
-
public final class BatchOptions extends Object
BatchOptions is used to createEventDataBatches.If you're creating
EventDataBatches withEventHubClient, then you can set a partitionKey and maxMessageSize using the .with() method. Alternatively, if you'd like the default settings, simply construct BatchOptions with the void constructor. Default settings: - partitionKey is null - maxMessageSize is the maximum allowed sizeIf you're creating
EventDataBatches withPartitionSender, then you can only set a maxMessageSize using the .with() method. Alternatively, if you'd like the default settings, simply construct BatchOptions with the void constructor. Default settings: - maxMessageSize is the maximum allowed size - Note: if you set a partition key, anIllegalArgumentExceptionwill be thrown.To construct either type of batch, create a
BatchOptionsobject and pass it into the appropriate createBatch method. If usingPartitionSender, then use (PartitionSender.createBatch(BatchOptions). If usingEventHubClient, then useEventHubClient.createBatch(BatchOptions).// Note: For all examples, 'client' is an instance of EventHubClient. The usage is the same for PartitionSender, however, you can NOT set a partition key when using PartitionSender // Create EventDataBatch with defaults EventDataBatch edb1 = client.createBatch(); // Create EventDataBatch with custom partitionKey BatchOptions options = new BatchOptions().with( options -> options.partitionKey = "foo"); EventDataBatch edb2 = client.createBatch(options); // Create EventDataBatch with custom partitionKey and maxMessageSize BatchOptions options = new BatchOptions().with ( options -> { options.partitionKey = "foo"; options.maxMessageSize = 100 * 1024; }; EventDataBatch edb3 = client.createBatch(options);
-
-
Field Summary
Fields Modifier and Type Field Description IntegermaxMessageSizeThe maximum size in bytes ofEventDataBatchbeing constructed.StringpartitionKeyThe partitionKey to use for allEventDatas sent in the currentEventDataBatch.
-
Constructor Summary
Constructors Constructor Description BatchOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchOptionswith(Consumer<BatchOptions> builderFunction)
-
-
-
Field Detail
-
partitionKey
public String partitionKey
The partitionKey to use for allEventDatas sent in the currentEventDataBatch. Setting a PartitionKey will deliver theEventDatato a specific Event Hubs partition.
-
maxMessageSize
public Integer maxMessageSize
The maximum size in bytes ofEventDataBatchbeing constructed. This value cannot exceed the maximum size supported by Event Hubs service.EventDataBatch.tryAdd(EventData)API will use this value as the upper limit.
-
-
Method Detail
-
with
public BatchOptions with(Consumer<BatchOptions> builderFunction)
-
-