Source
yaml
id: pubsub-realtime-trigger
namespace: company.team
tasks:
- id: insert_into_firestore
type: io.kestra.plugin.gcp.firestore.Set
projectId: test-project-id
collection: orders
document:
order_id: "{{ trigger.data | jq('.order_id') | first }}"
customer_name: "{{ trigger.data | jq('.customer_name') | first }}"
customer_email: "{{ trigger.data | jq('.customer_email') | first }}"
product_id: "{{ trigger.data | jq('.product_id') | first }}"
price: "{{ trigger.data | jq('.price') | first }}"
quantity: "{{ trigger.data | jq('.quantity') | first }}"
total: "{{ trigger.data | jq('.total') | first }}"
triggers:
- id: realtime_trigger
type: io.kestra.plugin.gcp.pubsub.RealtimeTrigger
projectId: test-project-id
topic: orders
subscription: kestra-subscription
serdeType: JSON
About this blueprint
Trigger Queue Realtime Trigger GCP
This flow will:
- Get triggered every time the event lands in the Pub/Sub topic
- The flow will push the data into Firestore table
For this, create a Pub/Sub topic named
orders
. We will be producing JSON messages into the Pub/Sub topic generated from the orders.csv. One sample produced message can be:{"order_id": "1", "customer_name": "Kelly Olsen", "customer_email": "[email protected]", "product_id": "20", "price": "166.89", "quantity": "1", "total": "166.89"}
Createorders
table in Firestore. When you produce the message onto Pub/Sub topic, the flow will get triggered, and you can see that a corresponding new record gets into the Firestore table.