You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/07/20 04:25:10 UTC

[GitHub] [pulsar-client-node] k2la opened a new pull request #106: Fix Cleanup Listener

k2la opened a new pull request #106:
URL: https://github.com/apache/pulsar-client-node/pull/106


   ### Motivation
   When the following code is executed, the node process is not finished in spite of consuming all messages and closing the consumer and client.
   
   ```
   const Pulsar = require('pulsar-client');
   
   (async () => {
     const client = new Pulsar.Client({
       serviceUrl: 'pulsar://localhost:6650',
     });
     let received = 0;
     let finish;
     const finishPromise = new Promise((resolve) => {
       finish = resolve;
     });
   
     const consumer = await client.subscribe({
       topic: 'persistent://public/default/my-topic',
       subscription: 'sub1',
       listener: (msg, msgConsumer) => {
         const data = msg.getData().toString();
         console.log(data);
         msgConsumer.acknowledge(msg);
         received += 1;
         if (received === 10) finish();
       },
     });
   
     await finishPromise;
     await consumer.close();
     await client.close();
   })();
   ```
   
   It seems that this happens because the registered listener function is not released.
   https://github.com/apache/pulsar-client-node/blob/master/src/Consumer.cc#L307 
   `this->listener->callback.Release();` is not executed because `this->listener` becomes `nullptr` when consumers are closed.
   
   ### Modification
   Fix so that the registered listener function is released when the consumer is closed.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar-client-node] nkurihar commented on pull request #106: Fix Cleanup Listener

Posted by GitBox <gi...@apache.org>.
nkurihar commented on pull request #106:
URL: https://github.com/apache/pulsar-client-node/pull/106#issuecomment-661704067


   test this please


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar-client-node] massakam merged pull request #106: Fix Cleanup Listener

Posted by GitBox <gi...@apache.org>.
massakam merged pull request #106:
URL: https://github.com/apache/pulsar-client-node/pull/106


   


----------------------------------------------------------------
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:
users@infra.apache.org