Skip to main content

PubSub

PubSub is a Dapr building block that enables you to publish and subscribe to messages between microservices. It decouples producers and consumers, allowing you to build scalable, event-driven systems.

Key Features

  • Supports multiple messaging backends (Azure Service Bus, Kafka, Redis, etc.)
  • Decouples services for improved scalability
  • At-least-once delivery guarantees
  • Dead-letter and retry support

Example Usage

// Publish an event using Dapr client
var client = new DaprClientBuilder().Build();
await client.PublishEventAsync("pubsub", "orders", orderData);

Real-World Application

You use PubSub to connect services that need to react to events, such as order creation, payment processing, or notifications. This pattern improves system resilience and scalability.