Python - topic.publish()
Publishes a topic.
from nitric.resources import topicfrom nitric.application import Nitricupdates = topic('updates').allow('publish')await updates.publish({'something': 'amazing happened'})Nitric.run()
Parameters
- Name
 event- Required
 - Required
 - Type
 - Event
 - Description
 The event to publish to the topic.
- Name
 id- Optional
 - Optional
 - Type
 - string
 - Description
 Unique ID to apply to the event.
- Name
 payload- Required
 - Required
 - Type
 - dict
 - Description
 Payload to send with the event.
- Name
 payloadType- Optional
 - Optional
 - Type
 - string
 - Description
 A hint to the type of payload supplied.
Examples
Publish a topic
from nitric.resources import topicfrom nitric.application import Nitricupdates = topic('updates').allow('publish')await updates.publish({'something': 'amazing happened'})Nitric.run()
Notes
- A service may subscribe to OR publish to a topic but not both. This is in place to stop services calling themselves infinitely.
 
Last updated on Oct 16, 2024