Home > Enterprise >  Firebase PubSub Trigger with Message Ordering
Firebase PubSub Trigger with Message Ordering

Time:01-21

does anyone know how to enable the Message Ordering property on a subscription when working with Firebase and NodeJs?

If I navigate to the GCP console and open the queue's subscription detail, I can change the parameter manually but I'd rather have it done when my functions deploy. Queue Subscription Details

This link (GCP Sample Code

Own Code

Own Code

CodePudding user response:

It sounds like you're asking if pubsub functions deployed with the Firebase CLI (and not gcloud) can request ordering. Currently, this is not possible. When you deploy a pubsub function with the Firebase CLI, it will automatically create the pubsub topic for you. However, there is no option to set the ordering setting.

If you would like see this implemented, you should file a feature request on the Firebase CLI GitHub and/or contact Firebase support directly.

Alternatively, you can switch to use gcloud to establish the trigger and create its pubsub topic with your customizations.

You should note that enabling ordering does not necessarily ensure that function invocations will be perfectly serialized with respect to incoming messages. Cloud Functions is designed for incoming events to be handled in parallel as fast as possible by using multiple server instances as needed. There is no guarantee that pubsub messages will be processed fully in order. The ordering only applies to pubsub topic consumer code that runs in a single process. You could try to set the max instances of a function to 1, but that is not a hard guarantee.

If you need fully ordered serialized execution of some code in response to pubsub events, maybe Cloud Functions isn't the product you want to use. Maybe a single App Engine or Compute Engine instance would work better.

  •  Tags:  
  • Related