apache/beam · error · RuntimeException

SolaceIO.Write: Trying to create a batch of

Error message

SolaceIO.Write: Trying to create a batch of ${records.size()}, but Solace supports a maximum of ${SOLACE_BATCH_LIMIT}. The batch will likely be rejected by Solace.

What it means

SolaceIO.Write throws this RuntimeException in MessageProducerUtils.createJCSMPSendMultipleEntry when a caller tries to build a transacted batch of more records than Solace supports in a single send-multiple (SOLACE_BATCH_LIMIT). Solace brokers reject oversized transacted send batches, so the connector fails fast before publishing a batch that would be rejected.

Solutions

  1. Reduce the writer's batch size configuration so each batch is <= SOLACE_BATCH_LIMIT.
  2. Chunk the record list before calling createJCSMPSendMultipleEntry and send multiple smaller batches.
  3. Check the SOLACE_BATCH_LIMIT constant in the connector version you use, since it caps batches at Solace's documented maximum.
  4. If batches come from bundle size, lower the pipeline's bundle/flush sizing for the Write transform.

Example fix

// before
JCSMPSendMultipleEntry[] batch = MessageProducerUtils.createJCSMPSendMultipleEntry(allRecords, useLatency, destFn, DeliveryMode.PERSISTENT);
// after
for (List<Solace.Record> chunk : Lists.partition(allRecords, SOLACE_BATCH_LIMIT)) {
  JCSMPSendMultipleEntry[] batch = MessageProducerUtils.createJCSMPSendMultipleEntry(chunk, useLatency, destFn, DeliveryMode.PERSISTENT);
  producer.sendMultiple(batch);
}
Defensive patterns

Strategy: validation

Validate before calling

if (records.size() > SOLACE_BATCH_LIMIT) {
  throw new IllegalArgumentException("Batch of " + records.size() + " exceeds Solace limit " + SOLACE_BATCH_LIMIT);
}

Try / catch

try { producer.sendMultiple(entries); } catch (RuntimeException e) { if (e.getMessage().contains("maximum of")) { /* split batch and resend */ } throw e; }

Prevention

When it happens

Trigger: Passing a `List<Solace.Record>` larger than the Solace batch limit (typically 50 messages) into `createJCSMPSendMultipleEntry(...)`, or configuring the Write transform so that buffered records per bundle/transaction exceed the limit.

Common situations: High-throughput writers with large batch-size configuration; grouping many elements in one bundle before flushing; using `withMaxBatchSize` (or equivalent) set above the broker's supported transacted batch limit.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/49d686aba1a3384e. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/broker/MessageProducerUtils.java:80

   * Create a {@link JCSMPSendMultipleEntry} array to be published in Solace. This can be used with
   * `sendMultiple` to send all the messages in a single API call.
   *
   * <p>The size of the list cannot be larger than 50 messages. This is a hard limit enforced by the
   * Solace API.
   *
   * @param records A {@link List} of records to be published
   * @param useCorrelationKeyLatency Whether to use a complex key for tracking latency.
   * @param destinationFn A function that maps every record to its destination.
   * @param deliveryMode The {@link DeliveryMode} used to publish the message.
   * @return A {@link JCSMPSendMultipleEntry} array that can be sent to Solace "as is".
   */
  public static JCSMPSendMultipleEntry[] createJCSMPSendMultipleEntry(
      List<Solace.Record> records,
      boolean useCorrelationKeyLatency,
      SerializableFunction<Solace.Record, Destination> destinationFn,
      DeliveryMode deliveryMode) {
    if (records.size() > SOLACE_BATCH_LIMIT) {
      throw new RuntimeException(
          String.format(
              "SolaceIO.Write: Trying to create a batch of %d, but Solace supports a"
                  + " maximum of %d. The batch will likely be rejected by Solace.",
              records.size(), SOLACE_BATCH_LIMIT));
    }

    JCSMPSendMultipleEntry[] entries = new JCSMPSendMultipleEntry[records.size()];
    for (int i = 0; i < records.size(); i++) {
      Solace.Record record = records.get(i);
      JCSMPSendMultipleEntry entry =
          JCSMPFactory.onlyInstance()
              .createSendMultipleEntry(
                  createMessage(record, useCorrelationKeyLatency, deliveryMode),
                  destinationFn.apply(record));
      entries[i] = entry;
    }

    return entries;

View on GitHub (pinned to 12126d8942)