Comments (16)
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.
Hi @g-ongenae @ccoeurderoy
Pls take a look at it whenever you guys are available.
from pubsub.
Thanks for looking @ccoeurderoy
from pubsub.
Hi @ccoeurderoy Is there any update on this?
from pubsub.
Yes, a pull request has been opened (#584) and should be soon released!
from pubsub.
thanks @ccoeurderoy
from pubsub.
FYI @ccoeurderoy
I tried subscription.close()
and subscription.removeAllListeners('message')
too but the subscription was not closed.
from pubsub.
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.
thanks, let me try
from pubsub.
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.
@gitSambhal Could you share a code snippet so I can reproduce this please?
from pubsub.
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.
Hi @ccoeurderoy @meriamBenSassi
The package is not yet updated on the npm, can you pls trigger the new release?
from pubsub.
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.
Hi @meriamBenSassi @g-ongenae
Can you pls release it?
from pubsub.
🎉 This issue has been resolved in version 6.2.0 🎉
The release is available on:
v6.2.0
- GitHub release
Your semantic-release bot 📦🚀
from pubsub.
Related Issues (12)
- The automated release is failing 🚨
- event name used to create topic and subscription HOT 3
- Tests are failing locally HOT 1
- A way to pass subscription options/metadata HOT 12
- It is blocking the event loop HOT 3
- Google never acknowledge that the event has been received and send it again and again. HOT 2
- How to set orderingKey in Nestjs ? HOT 1
- Upgrade to @google-cloud/pubsub 3.5.1 HOT 2
- Prevent auto create topic HOT 5
- autoAck: false not supported HOT 3
- Request: Subscription character separator HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pubsub.