shibd commented on issue #339: URL: https://github.com/apache/pulsar-client-node/issues/339#issuecomment-1680644792
> I was wondering if there's a way to ensure messages will be received by the same consumer in a key shared sub ? Because so far I could not achieve that with keys. 1. Consumers need to use KeyShared subscription type. 2. and your producer need use [KeyBased batchType](https://pulsar.apache.org/docs/3.0.x/concepts-messaging/#batching-for-key-shared-subscriptions) (Node.js client is not yet implemented). Now you can disabled the producer batch first. ``` // Create a producer and disabled batch const producer = await client.createProducer({ topic: 'persistent://public/default/my-topic', sendTimeoutMs: 30000, batchingEnabled: false, }); // Create a consumer and use KeyShared sub type. const consumer = await client.subscribe({ topic: 'persistent://public/default/my-topic', subscription: 'sub1', subscriptionType: 'KeyShared', ackTimeoutMs: 10000, }); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
