File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
daprdocs/content/en/developing-applications/building-blocks/pubsub Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,26 @@ with DaprClient() as client:
108108 topic_name = ' orders' ,
109109 publish_metadata = {' cloudevent.id' : ' d99b228f-6c73-4e78-8c4d-3f80a043d317' , ' cloudevent.source' : ' payment' }
110110 )
111+
112+ # or
113+
114+ cloud_event = {
115+ ' specversion' : ' 1.0' ,
116+ ' type' : ' com.example.event' ,
117+ ' source' : ' payment' ,
118+ ' id' : ' d99b228f-6c73-4e78-8c4d-3f80a043d317' ,
119+ ' data' : {' orderId' : i},
120+ ' datacontenttype' : ' application/json' ,
121+ ...
122+ }
123+
124+ # Set the data content type to 'application/cloudevents+json'
125+ result = client.publish_event(
126+ pubsub_name = ' order_pub_sub' ,
127+ topic_name = ' orders' ,
128+ data = json.dumps(cloud_event),
129+ data_content_type = ' application/cloudevents+json' ,
130+ )
111131```
112132
113133{{% /codetab %}}
You can’t perform that action at this time.
0 commit comments