### YamlMime:JavaType uid: "com.microsoft.azure.eventhubs.BatchOptions" fullName: "com.microsoft.azure.eventhubs.BatchOptions" name: "BatchOptions" nameWithType: "BatchOptions" summary: "BatchOptions is used to create es." inheritances: - "" inheritedClassMethods: - classRef: "java.lang.Object" methodsRef: - "clone" - "equals" - "finalize" - "getClass" - "hashCode" - "notify" - "notifyAll" - "toString" - "wait" - "wait" - "wait" syntax: "public final class **BatchOptions**" constructors: - uid: "com.microsoft.azure.eventhubs.BatchOptions.BatchOptions()" fullName: "com.microsoft.azure.eventhubs.BatchOptions.BatchOptions()" name: "BatchOptions()" nameWithType: "BatchOptions.BatchOptions()" syntax: "public BatchOptions()" fields: - uid: "com.microsoft.azure.eventhubs.BatchOptions.maxMessageSize" fullName: "com.microsoft.azure.eventhubs.BatchOptions.maxMessageSize" name: "maxMessageSize" nameWithType: "BatchOptions.maxMessageSize" summary: "The maximum size in bytes of being constructed." field: type: "Integer" syntax: "public Integer maxMessageSize" desc: "The maximum size in bytes of being constructed. This value cannot exceed the maximum size supported by Event Hubs service. API will use this value as the upper limit." - uid: "com.microsoft.azure.eventhubs.BatchOptions.partitionKey" fullName: "com.microsoft.azure.eventhubs.BatchOptions.partitionKey" name: "partitionKey" nameWithType: "BatchOptions.partitionKey" summary: "The partitionKey to use for all s sent in the current ." field: type: "String" syntax: "public String partitionKey" desc: "The partitionKey to use for all s sent in the current . Setting a PartitionKey will deliver the to a specific Event Hubs partition." methods: - uid: "com.microsoft.azure.eventhubs.BatchOptions.with(java.util.function.Consumer)" fullName: "com.microsoft.azure.eventhubs.BatchOptions.with(Consumer builderFunction)" name: "with(Consumer builderFunction)" nameWithType: "BatchOptions.with(Consumer builderFunction)" parameters: - name: "builderFunction" type: "Consumer<>" syntax: "public BatchOptions with(Consumer builderFunction)" returns: type: "" type: "class" desc: "BatchOptions is used to create es.\n\nIf you're creating es with , 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\n\nIf you're creating es with , 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 will be thrown.\n\nTo construct either type of batch, create a object and pass it into the appropriate createBatch method. If using , then use (. If using , then use .\n\n```java\n// Note: For all examples, 'client' is an instance of EventHubClient. The usage is the same for PartitionSender,\n however, you can NOT set a partition key when using PartitionSender\n\n // Create EventDataBatch with defaults\n EventDataBatch edb1 = client.createBatch();\n\n // Create EventDataBatch with custom partitionKey\n BatchOptions options = new BatchOptions().with( options -> options.partitionKey = \"foo\");\n EventDataBatch edb2 = client.createBatch(options);\n\n // Create EventDataBatch with custom partitionKey and maxMessageSize\n BatchOptions options = new BatchOptions().with ( options -> {\n options.partitionKey = \"foo\";\n options.maxMessageSize = 100 * 1024;\n };\n EventDataBatch edb3 = client.createBatch(options);\n```" metadata: {} package: "com.microsoft.azure.eventhubs" artifact: com.microsoft.azure:azure-eventhubs:3.2.2