BatchOptions Class
- java.
lang. Object - com.
microsoft. azure. eventhubs. BatchOptions
- com.
public final class BatchOptions
BatchOptions is used to create EventDataBatches.
If you're creating EventDataBatches with EventHubClient, 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 size
If you're creating EventDataBatches with PartitionSender, 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, an IllegalArgumentException will be thrown.
To construct either type of batch, create a BatchOptions object and pass it into the appropriate createBatch method. If using PartitionSender, then use (createBatch(BatchOptions options). If using EventHubClient, then use createBatch(BatchOptions options).
// 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
Modifier and Type | Field and Description |
---|---|
Integer |
maxMessageSize
The maximum size in bytes of EventDataBatch being constructed. |
String |
partitionKey
The partition |
Constructor Summary
Constructor | Description | |
---|---|---|
BatchOptions() |
Method Summary
Modifier and Type | Method and Description |
---|---|
Batch |
with(Consumer<BatchOptions> builderFunction) |
Methods inherited from java.lang.Object
Field Details
maxMessageSize
public Integer maxMessageSize
The maximum size in bytes of EventDataBatch being constructed. This value cannot exceed the maximum size supported by Event Hubs service. tryAdd(EventData eventData) API will use this value as the upper limit.
partitionKey
public String partitionKey
The partitionKey to use for all EventDatas sent in the current EventDataBatch. Setting a PartitionKey will deliver the EventData to a specific Event Hubs partition.
Constructor Details
BatchOptions
public BatchOptions()
Method Details
with
public BatchOptions with(Consumer
Parameters:
Applies to
Azure SDK for Java
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기