nodejs-pubsub | js client for Google Cloud Pub | Pub Sub library
kandi X-RAY | nodejs-pubsub Summary
kandi X-RAY | nodejs-pubsub Summary
Cloud Pub/Sub is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. This document contains links to an API reference, samples, and other resources useful to developing Node.js applications. For additional help developing Pub/Sub applications, in Node.js and other languages, see our Pub/Sub quickstart, publisher, and subscriber guides. A comprehensive list of changes in each version may be found in the CHANGELOG. Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nodejs-pubsub
nodejs-pubsub Key Features
nodejs-pubsub Examples and Code Snippets
import { NestFactory } from '@nestjs/core'
import { GCloudPubSubServer } from 'nodejs-gcloud-pubsub-module'
import { ApplicationModule } from './app.module'
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule)
cons
Community Discussions
Trending Discussions on nodejs-pubsub
QUESTION
I'm trying to setup a GCP PubSub service that will work with a push type subscription. However it's impossible to create one in the developement stage, while I have no accessible endpoints.
I assumed that the emulator would allow me to specify a local endpoint so that the service would run flawlessly in local.
However, after setting it up, I couldn't find a way in the Node.js pubsub library to create a subscription while specifying its options, there is no example for this.
This is the pretty simple way to create a simple, default, pull, subscription:
...ANSWER
Answered 2019-Aug-30 at 15:43Here is an example of how you would set up push subscription. It is the same as how you would set it up if you were running in the actual Pub/Sub environment. Specify ‘pushEndpoint’ as your local endpoint. When running on the emulator, it will not require authentication for your endpoint.
You can do something like the following:
QUESTION
We have an architecture using 2 pubsub topic/subscription pairs:
- Topic
T1
is triggered by a cronjob periodically (every 5 minutes for example). SubscriptionS1
is the trigger for our cloud function. - Topic
T2
serves as a queue for background jobs that are published by one of our services. SubscriptionS2
is read by the cloud function on each execution to service the queued background jobs.
This allows us to control the frequency the background jobs are serviced independent of when they are added to the queue.
The cloud function (triggered by S1
) reads messages from S2
by pulling. It decides which background jobs are ready and upon successfully servicing the job, it ACK's the associated messages. Jobs not ready or failed are not ACK'ed to be serviced later.
We have issues using the official node.js pubusb client from google:
- Sometimes ACK'ed messages re-appear (seeming infinitely). We verified the messages are acked before the ACK deadline and are sure we are calling
ack()
by investigating our logs. - Sometimes after the first execution (after re-deploying the function), subsequent executions never receive new messages. We can verify the messages are queued in subscription
S2
either by verifying the unacknowledged message count in stackdriver or by re-deploying the function and seeing the messages getting serviced.
We believe this is a problem with google's node.js pubsub client. The cloud function docs clearly state not start background activities. However, looking into the node.js pubsub client source, it clearly services acknowledgements in the background using timeouts.
Is google's node.js pubsub client not compatible with google cloud functions? Google recommends accessing the service API's only when a client library does not exist or does not meet other needs. Is running the client in a cloud function "other needs", requiring us to write our own client using the service API's?
Workaround attempted:As a "workaround" we tried delaying the end of the execution of the cloudfunction to allow any "background" processes in the node.js pubsub client to complete, but this did not consistently eliminate our issue. It seems that pubsub client is not cloud function friendly and cannot recover from being stopped in between cloud function executions.
Update Feb. 22, 2018I wrote an article on our blog that describes in detail why we used PubSub in this way and how we are working around the fact that node.js pubsub client is not compatible with cloud functions.
...ANSWER
Answered 2018-Feb-22 at 13:30A developer from the node.js pubsub client confirmed that using the client to pull messages from a Cloud Function is not a supported use case.
The alternative is to use the service APIs. However, the REST APIs have their own caveats when attempting to pull all messages from a subscription.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nodejs-pubsub
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page