rafael-polakiewicz opened a new issue, #390:
URL: https://github.com/apache/pulsar-client-node/issues/390

   # Description
   I encountered a segmentation fault using pulsar consumer batch receive 
method. The consumer process terminates unexpectedly with a segmentation fault.
   
   # Node and pulsar-client info
   - node version: v20.15.0
   - pulsar-client: "^1.11.0"
   
   
   # Steps to Reproduce
   ## 1. Start a local instance of Pulsar
   
   Use the following docker-compose file to start a Pulsar instance:
   ```yaml
   services:
     pulsar:
       image: apachepulsar/pulsar:3.3.0
       command: "bin/pulsar standalone"
       ports:
           - '7128:8080'
           - '6650:6650'
       volumes:
           - pulsar_data:/pulsar/data
           - pulsar_conf:/pulsar/conf
   
   volumes:
     pulsar_data:
     pulsar_conf:
   ```
   ## 2. Create a simple consumer script
   Save the following code in a file named consumer.js:
   
   ```javascript
   const Pulsar = require('pulsar-client');
   
   async function main() {
     const client = new Pulsar.Client({
       serviceUrl: 'pulsar://localhost:6650',
     });
   
     const consumer = await client.subscribe({
       subscription: 'example-subscription',
       subscriptionType: 'Shared',
       topic: 'persistent://public/default/my-topic',
       batchReceivePolicy: {
         timeoutMs: 3000,
         maxNumMessages: 10
       }
     });
   
     console.log('consumer created');
   
     while (true) {
       const messages = await consumer.batchReceive();
       messages.forEach(async (msg) => {
         console.log({ msg: msg.getData().toString() });
         await consumer.acknowledge(msg);
       });
     }
   }
   
   main();
   ```
   
   ## 3. Run the consumer script
   
   Execute the script using the following command:
   ```sh
   node consumer.js
   ```
   
   ## 4. Create a producer script
   
   Save the following code in a file named producer.js:
   
   ```javascript
   const Pulsar = require('pulsar-client');
   
   async function main() {
     const client = new Pulsar.Client({
       serviceUrl: 'pulsar://localhost:6650',
     });
   
     const producer = await client.createProducer({
       topic: 'persistent://public/default/my-topic',
       blockIfQueueFull: true,
     });
   
     for (let i = 0; i < 100; i++) {
       console.log(`sent message ${i}`);
       await producer.send({
         data: Buffer.from("test"),
       });
     }
   }
   
   main();
   ```
   ## 5. Populate the topic
   
   Execute the producer script using the following command:
   ```sh
   node producer.js
   ```
   ## Expected Behavior
   The consumer should process and acknowledge messages without errors.
   
   ## Actual Behavior
   The consumer process ends with the following message:
   
   ```sh
   consumer created
   zsh: segmentation fault (core dumped)  node consumer.js
   ```
   
   # Additional Information
   I found that the [feature 
request](https://github.com/apache/pulsar-client-node/issues/274) to support 
batch receive was closed. Am I doing something wrong here, or is this a bug?
   Please let me know if you need any further information.
   
   Thank you for your attention to this matter.


-- 
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]

Reply via email to