Files
app-store-optimization/skills/dbos-golang/references/comm-messages.md
Max dml 7e5abd504f feat: add DBOS skills for TypeScript, Python, and Go (#94)
Add three DBOS SDK skills with reference documentation for building
reliable, fault-tolerant applications with durable workflows.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 23:26:51 +01:00

2.0 KiB

title, impact, impactDescription, tags
title impact impactDescription tags
Use Messages for Workflow Notifications MEDIUM Enables reliable inter-workflow and external-to-workflow communication communication, messages, send, recv, notification

Use Messages for Workflow Notifications

Use dbos.Send to send messages to a workflow and dbos.Recv to receive them. Messages are queued per topic and persisted for reliable delivery.

Incorrect (using external messaging for workflow communication):

// External message queue is not integrated with workflow recovery
ch := make(chan string) // Not durable!

Correct (using DBOS messages):

func checkoutWorkflow(ctx dbos.DBOSContext, orderID string) (string, error) {
	// Wait for payment notification (timeout 120 seconds)
	notification, err := dbos.Recv[string](ctx, "payment_status", 120*time.Second)
	if err != nil {
		return "", err
	}

	if notification == "paid" {
		_, err = dbos.RunAsStep(ctx, func(ctx context.Context) (string, error) {
			return fulfillOrder(orderID)
		}, dbos.WithStepName("fulfillOrder"))
		return "fulfilled", err
	}
	_, err = dbos.RunAsStep(ctx, func(ctx context.Context) (string, error) {
		return cancelOrder(orderID)
	}, dbos.WithStepName("cancelOrder"))
	return "cancelled", err
}

// Send a message from a webhook handler
func paymentWebhook(ctx dbos.DBOSContext, workflowID, status string) error {
	return dbos.Send(ctx, workflowID, status, "payment_status")
}

Key behaviors:

  • Recv waits for and consumes the next message for the specified topic
  • Returns the zero value if the wait times out, with a DBOSError with code TimeoutError
  • Messages without a topic can only be received by Recv without a topic
  • Messages are queued per-topic (FIFO)

Reliability guarantees:

  • All messages are persisted to the database
  • Messages sent from workflows are delivered exactly-once

Reference: Workflow Messaging and Notifications