You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 30, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/infra/pubsub/index.md
+26-9
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
2
title: "Google PubSub"
3
-
description: "Producers and subscriptions for Google PubSub"
3
+
description: "Producers and subscriptions for Google Pub/Sub"
4
4
sidebar_position: 6
5
5
---
6
6
7
7
Pub/Sub is an asynchronous and scalable messaging service that decouples services producing messages from services processing those messages. [source](https://cloud.google.com/pubsub/docs/overview).
8
8
9
-
Eventuous supports producing and consuming messages using Google PubSub. Use the `Eventuous.GooglePubSub` NuGet package to get started.
9
+
Eventuous supports producing and consuming messages using Google Pub/Sub. Use the `Eventuous.GooglePubSub` NuGet package to get started.
10
10
11
11
## Producer
12
12
@@ -25,9 +25,9 @@ var producer = new GooglePubSubProducer(
25
25
);
26
26
```
27
27
28
-
You can register the producer in the service collection using the `AddProducer` extension method. It's recommended to go that way because Google PubSub producer needs to be started and shut down following the application lifecycle, which is done automatically when you use the `AddProducer` registration helper.
28
+
You can register the producer in the service collection using the `AddProducer` extension method. It's recommended to go that way because Google Pub/Sub producer needs to be started and shut down following the application lifecycle, which is done automatically when you use the `AddProducer` registration helper.
29
29
30
-
Behind the scenes, the producer will create a separate PubSub client instance per topic, as the PubSub API only allows to use one client to work with a single topic. The producer will cache the client instances, so you don't need to worry about creating too many clients.
30
+
Behind the scenes, the producer will create a separate Pub/Sub client instance per topic, as the Pub/Sub API only allows to use one client to work with a single topic. The producer will cache the client instances, so you don't need to worry about creating too many clients.
31
31
32
32
Producing messages is done using the `Produce` method. You can produce a single message or a batch of messages. The `Produce` method returns a `Task` that completes when the message is produced.
Eventuous allows you to consume messages from Google PubSub, which are published by other services using the Eventuous PubSub producer. Theoretically, it can also consume messages from other producers, but it expects the message to have the `eventType` and `contentType` attributes set, which might not be the case for other producers. However, if an external producer sets some attributes that can be used for the event type and content type, you can override the default attribute names in subscription options.
48
+
Eventuous allows you to consume messages from Google Pub/Sub, which are published by other services using the Eventuous Pub/Sub producer. Theoretically, it can also consume messages from other producers, but it expects the message to have the `eventType` and `contentType` attributes set, which might not be the case for other producers. However, if an external producer sets some attributes that can be used for the event type and content type, you can override the default attribute names in subscription options.
49
49
50
50
Normally, you'd add the subscription to the service collection using `AddSubscription` extension method, as any other Eventuous subscription.
51
51
@@ -65,7 +65,7 @@ services
65
65
);
66
66
```
67
67
68
-
Similarly to the producer, the Eventuous subscription can create a PubSub subscription if it does not exist. Creating a subscription is a one-time operation, so you can set this option to `false` after the subscription is created. Often, you would have a separate process that creates topics and subscriptions, so the `CreateSubscription` option is set to `false` by default.
68
+
Similarly to the producer, the Eventuous subscription can create a Pub/Sub subscription if it does not exist. Creating a subscription is a one-time operation, so you can set this option to `false` after the subscription is created. Often, you would have a separate process that creates topics and subscriptions, so the `CreateSubscription` option is set to `false` by default.
69
69
70
70
If you expect to consume messages from non-Eventuous producers that provide event type and content type information in message attributes, but those attribute names don't match Eventuous conventions, you can override those attribute names in subscription options.
71
71
@@ -78,8 +78,25 @@ options.Attributes = new PubSubAttributes {
78
78
79
79
## Cloud Run subscription
80
80
81
-
Google PubSub messages can be used as Cloud Run triggers. Eventuous supports a lightweight subscription that can be used with the Cloud Run trigger. Use the `Eventuous.GooglePubSub.CloudRun` NuGet package to use it.
81
+
Google Pub/Sub messages can be used as Cloud Run triggers. Eventuous supports a lightweight subscription that can be used with the Cloud Run trigger. Use the `Eventuous.GooglePubSub.CloudRun` NuGet package to use it.
82
82
83
-
Essentially, the Cloud Run subscription creates an HTTP endpoint conforming the PubSub trigger API. It allows your application to receive PubSub messages as HTTP requests.
83
+
Essentially, the Cloud Run subscription creates an HTTP endpoint conforming the Pub/Sub trigger API. It allows your application to receive Pub/Sub messages as HTTP requests.
84
84
85
-
_To be completed with samples_
85
+
Cloud Run subscription set up is the same as for any other subscription, but it requires one additional step to map the HTTP endpoint.
The `MapCloudRunPubSubSubscription` extension method maps the subscription HTTP endpoint to the specified path. The path you provide there must match the path of your Cloud Run trigger for Pub/Sub, which you specified as the push endpoint. The push endpoint URL should be composed of your Cloud Run workload URL, combined with the path configured by `MapCloudRunPubSubSubscription`. Root path is the default value.
101
+
102
+
Read mode about configuring push subscriptions in the [Google Cloud Run documentation](https://cloud.google.com/run/docs/triggering/pubsub-push#create-push-subscription).
0 commit comments