Slide 39
Slide 39 text
Dapr Pub/Sub API
const client = new DaprClient({ daprHost, daprPort });
const order = { orderId: 1 };
await client.pubsub.publish(“mypubsub”, “new-orders”, order);
Publish
Subscribe (Dapr pushes each message to the app)
const server = new DaprServer({ serverHost, serverPort,
clientOptions: { daprHost, daprPort }
});
server.pubsub.subscribe(“mypubsub”, “new-orders”, data =>
console.log("Received:" + JSON.stringify(data))
);
await server.start();
stop, err := cl.SubscribeWithHandler(context.Background(),
client.SubscriptionOptions{
PubsubName: "pubsub",
Topic: "orders",
},
eventHandler,
)
Streaming Subscription (Bidirectional stream between app/sidecar )
Features
● Integrates with many message brokers and queues
● Push or Pull mode for subscriptions
● Content-based message routing and filtering
● Aggregator/Splitter through message batches
● Dead-letter topics and resiliency policies
● Access control per topic
● Message expiration
● Delayed delivery (coming soon)