Skip to content

Clarification on documentation: "eachBatch’s batch size never exceeds 1.*" #350

@vikas-goswami

Description

@vikas-goswami

Hi Team,

We are migrating to Javascript client from KafkaJS and using APIs under:
const { Kafka } = require("@confluentinc/kafka-javascript").KafkaJS;

We would like to understand what does this statement mean in migration documentation present here: reference to doc

The statement mentions:
eachBatch’s batch size never exceeds 1.
However, doesn't that mean eachBatch will behave just like eachMessage since size is limited to 1?

I tried to do a quick POC with this snippet:

        await consumer.run({
            eachBatch: async ({ batch, resolveOffset, heartbeat, isRunning, isStale }) => {
                console.log(`[${instanceId}] Received batch with ${batch.messages.length} messages`);
                console.log(`[${instanceId}] Batch info:`, {
                    topic: batch.topic,
                    partition: batch.partition,
                    firstOffset: batch.firstOffset(),
                    lastOffset: batch.lastOffset()
                });

                for (const message of batch.messages) {
                    if (!isRunning() || isStale()) break;
                    
                    console.log(`[${instanceId}] Processing message:`, {
                        offset: message.offset,
                        value: message.value.toString()
                    });
                    
                    await resolveOffset(message.offset);
                    //await heartbeat();
                    console.log(`[${instanceId}] Started`);
                    for (let i = 0; i < 10000000; ) { 
                        // Simulate processing delay
                        i++;
                    }
                    console.log(`[${instanceId}] Done`);

                }
            }
        });

and I could see in logs that batch size is coming as more than 1 frequently, proving that no such limit is not in place.

So, can you please clarify what this statement means: eachBatch’s batch size never exceeds 1. and if there are any plans to limit eachBatch's size to 1 since it will affect our migration.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationquestionA question is asked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy