Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
818 views
in Technique[技术] by (71.8m points)

How to deploy pubsub-triggered cloud function with message ordering?

I want to deploy a Pubsub-triggered Cloud Function with message ordering: https://cloud.google.com/pubsub/docs/ordering

gcloud functions deploy doesn't have an option to set an --enable-message-ordering option: https://cloud.google.com/sdk/gcloud/reference/functions/deploy

Should I pre-create the subscription before deploying the function? If so, does Cloud Functions have a well-known format for how it matches to a subscription name? It seems maybe the format is: gcf-{function-name}-{region}-{topic-name}, but it also looks like the name format has changed over time, e.g. older deployed functions don't have the region name in the subscription. Is there a stable way to do this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You must create message ordering pub/sub and Cloud function manually.

Fisrt, Create a pub/sub topic, and then create a subscription that subscribes pub/sub topic with --enable-message-ordering

Second, Create a Cloud function that will serve ordered pub/sub messages.

Last, back to the pub/sub subscription, Edit delivery type to push and specify your cloud function endpoint.

enter image description here

So final diagram is like below.

Publisher -> Pub/sub topic -> Pub/sub subscriber -> Cloud function

You tried to make a connection Pub/sub topic with Cloud function directly.

But for message ordering, Pub/sub needs topic -> subscriber connection.

So only pub/sub topic -> pub/sub subscriber -> Cloud function connection can delivers ordered messages to your function.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...