yosiat opened a new pull request #85: Create reference for client
URL: https://github.com/apache/pulsar-client-node/pull/85
 
 
   Since we don’t have reference for the client, v8 can garbage collect this 
instance, which can cause the next code:
   
   ```
   const Pulsar = require('pulsar-client');
   
   (async () => {
     // Create a client
     const client = new Pulsar.Client({
       serviceUrl: 'pulsar://localhost:6650'
     });
   
     // Create a producer
     const producer = await client.createProducer({
       topic: 'persistent://public/default/my-topic',
       sendTimeoutMs: 30000,
       batchingEnabled: true,
     });
   
     let i =0;
     async function produceMessage() {
       i = i + 1;
   
       const msg = `my-message-${i}`;
       const ret = await producer.send({
         data: Buffer.from(msg),
       });
       console.log(`Sent message: ${msg}`);
       console.log(ret);
   
       setTimeout(produceMessage, 1000);
     }
   
     produceMessage();
   })();
   ```
   
   To close the connection suddenly and fail the producer.
   
   
   Fixes: https://github.com/apache/pulsar-client-node/issues/78
   

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