Giter Club home page Giter Club logo

Comments (16)

ccoeurderoy avatar ccoeurderoy commented on September 18, 2024 1

Hey @gitSambhal,

I've created an example app to test the close() method and indeed, it looks like it doesn't close the subscription connection. I am looking for a proper way to do this! I let you know when I find something

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

Hi @g-ongenae @ccoeurderoy
Pls take a look at it whenever you guys are available.

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

Thanks for looking @ccoeurderoy

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

Hi @ccoeurderoy Is there any update on this?

from pubsub.

ccoeurderoy avatar ccoeurderoy commented on September 18, 2024

Yes, a pull request has been opened (#584) and should be soon released!

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

thanks @ccoeurderoy

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

FYI @ccoeurderoy
I tried subscription.close() and subscription.removeAllListeners('message') too but the subscription was not closed.

from pubsub.

ccoeurderoy avatar ccoeurderoy commented on September 18, 2024

In the meantime, you can try to get the subscription from cache using the pubsub client:

const cachedSubscription = pubsub.subscriptions.get('name_of_your_subscription');
await cachedSubscription.close()

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

thanks, let me try

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

In the meantime, you can try to get the subscription from cache using the pubsub client:

const cachedSubscription = pubsub.subscriptions.get('name_of_your_subscription');
await cachedSubscription.close()

Not working. Tried the following also but to no luck

await pubsub.client.close();
await pubsub.client.closeAllClients_();
pubsub.subscriptions.forEach(async (sub) => await sub.close());

from pubsub.

ccoeurderoy avatar ccoeurderoy commented on September 18, 2024

@gitSambhal Could you share a code snippet so I can reproduce this please?

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

Hi @ccoeurderoy
I have the code something similar to this

let pubsub;

const configPubsub = (options) => {
  pubsub = PubSubFactory.create({
    options,
    transport: Transport.GOOGLE_PUBSUB,
  });
}

const closeConnection = async () => {
  if (pubsub?.client) {
    await pubsub.client.close();
    await pubsub.client.closeAllClients_();
    pubsub.subscriptions.forEach(async (sub) => await sub.close());
  }
}

const getOptionsFromServer = () => {
  // get options from server
}

// Simulating the cron job
setInterval( async () => {
  const options = await getOptionsFromServer();
  await closeConnection();
  configPubsub(options);
  
  await pubsub.listen(options.topicName, {
    autoAck: true,
    onMessage: (data) => {
      console.log(data);
    },
  });

}, 5000)

If in first iteration the topicName is topic1 and in next iteration the topic name is changed then the message is still received for the first topic i.e. topic1.

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

Hi @ccoeurderoy @meriamBenSassi
The package is not yet updated on the npm, can you pls trigger the new release?
image

from pubsub.

ccoeurderoy avatar ccoeurderoy commented on September 18, 2024

Unfortunately I'm no longer an admin for this project, so we must ask Algoan's members to do it! (@meriamBenSassi @g-ongenae)

from pubsub.

gitSambhal avatar gitSambhal commented on September 18, 2024

Hi @meriamBenSassi @g-ongenae
Can you pls release it?

from pubsub.

algoanbot avatar algoanbot commented on September 18, 2024

🎉 This issue has been resolved in version 6.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from pubsub.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.