yosiat opened a new pull request #83: Consumer with message listener dies after 
some time
URL: https://github.com/apache/pulsar-client-node/pull/83
 
 
   This PR:
   - Moves message listener to consumer
   - Use a single consumer instance
   
   The issue I am solving can be reproduced here:
   ```
   const Pulsar = require('pulsar-client');
   
   const readline = require('readline');
   
   const rl = new readline.createInterface({
     input: process.stdin,
     output: process.stdout
   })
   
   function prompt() {
     return new Promise((resolve) => {
       rl.question(`press any-key to close`, () => resolve());
     })
   }
   
   (async () => {
     // Create a client
     const client = new Pulsar.Client({
       serviceUrl: 'pulsar://localhost:6650'
     });
   
     // Create a consumer
     const consumer = await client.subscribe({
       topic: 'persistent://public/default/my-topic',
       subscription: 'sub1',
       subscriptionType: 'Shared',
       ackTimeoutMs: 10000,
       listener: function(msg) {
         console.log(msg.getData().toString());
         consumer.acknowledge(msg);
       }
     });
   
     await prompt();
     await consumer.close();
     await client.close();
   
   })();
   ```
   
   This code after some-time will close it's a connection, after this PR it 
works.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to