Skip to content

Need help with adding Key_Based batching support to producer config #417

@joshua-motorq

Description

@joshua-motorq

#267

I am working on adding Key_Based batching to the producer configuration. @BewareMyPower thank you for pointing me in this direction

I just have some questions regarding the C function use

I have updated the type in index.d.ts

export interface ProducerConfig {
  topic: string;
  producerName?: string;
  sendTimeoutMs?: number;
  initialSequenceId?: number;
  maxPendingMessages?: number;
  maxPendingMessagesAcrossPartitions?: number;
  blockIfQueueFull?: boolean;
  messageRoutingMode?: MessageRoutingMode;
  hashingScheme?: HashingScheme;
  compressionType?: CompressionType;
  batchingEnabled?: boolean;
  batchingMaxPublishDelayMs?: number;
  batchingMaxMessages?: number;
  _**batchingType?: BatchingType;**_
  properties?: { [key: string]: string };
  publicKeyPath?: string;
  encryptionKey?: string;
  cryptoFailureAction?: ProducerCryptoFailureAction;
  chunkingEnabled?: boolean;
  schema?: SchemaInfo;
  accessMode?: ProducerAccessMode;
}

export type BatchingType =
  'DefaultBatching' |
  'KeyBasedBatching';

I am having some difficulty with the setting of this property.

I was not able to find a direct function like pulsar_producer_configuration_set_batching_type similar to how pulsar_producer_configuration_set_access_mode exists

So i went with using the pulsar_producer_configuration_set_property function.

if (producerConfig.Has(CFG_BATCHING_TYPE) && producerConfig.Get(CFG_BATCHING_TYPE).IsString()) {
    std::string batchingType = producerConfig.Get(CFG_BATCHING_TYPE).ToString().Utf8Value();
    pulsar_producer_configuration_set_property(this->cProducerConfig.get(), "batchingType",
                                               batchingType.c_str());
  }

However, i am not able to see the expected behaviour when i test after installing the library locally. The entire batch gets sent to one consumer (based on the first key) behaving the same as default batching

I will create a PR for this once i verify it working

Could i please get some help with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions