Communicating with Workflows
DBOS provides a few different ways to communicate with your workflows. You can:
- Send messages to workflows
- Publish events from workflows for clients to read
- Stream values from workflows to clients
Workflow Messaging and Notifications
You can send messages to a specific workflow. This is useful for signaling a workflow or sending notifications to it while it's running.
Send
DBOS.send(
destination_id: str,
message: Any,
topic: Optional[str] = None
) -> None
You can call DBOS.send() to send a message to a workflow.
Messages can optionally be associated with a topic and are queued on the receiver per topic.
You can also call send from outside of your DBOS application with the DBOS Client
or with the 'dbos.send_message' PL/pgSQL function
Recv
DBOS.recv(
topic: Optional[str] = None,
timeout_seconds: float = 60,
) -> Any
Workflows can call DBOS.recv() to receive messages sent to them, optionally for a particular topic.
Each call to recv() waits for and consumes the next message to arrive in the queue for the specified topic, returning None if the wait times out.
If the topic is not specified, this method only receives messages sent without a topic.