Skip to content

Dapr enabled Microsoft Orleans services utilizing outbox pattern implementation with Postgres Logical Replication for communicating over Dapr pub/sub.

License

Notifications You must be signed in to change notification settings

modabas/lab-dapr-with-famous-actors-take2

Repository files navigation

lab-dapr-with-famous-actors-take2

Dapr enabled Microsoft Orleans services co-hosted with grpc service in same generic host.

WebApi service layer doesn't use orleans client to reach orleans silo, since it can call orleans silo directly since they are hosted in same generic host.

Publisher and consumer services communicate over Dapr event publishing utilizing outbox pattern over Postgresql database and Logical Replication. Postgresql replication messages are processed by a grain service in same Orleans silo as publisher, these messages are written to RabbitMq over Dapr pub/sub.

Microsoft Orleans:

Dapr has actor support based on Microsoft Orleans.

But since this is a .Net project, we can cast most famous actors for our project by utilizing Microsoft Orleans for our dapr enabled services. Since Orleans is around for much longer, it has many more features not yet implemented by Dapr actors.

Outbox Pattern:

Whenever data is written to a table in Postgres db, an event can be written to an outbox table in same Postgres Db within same DbTransaction.

Change Data Capture:

When a record is added to outbox table, a listener service is notified via Postgres Logical Replication which processes and publishes said record to Dapr.

Debugging:

Dapr Sidekick for .Net helps immensely to setting up a Dapr enabled .Net application project and also debugging experience.

Distributed tracing & logging support:

Asp.Net Core, Postgresql and Dapr has distributed tracing support out of the box. Also Microsoft Orleans supports it starting from 7.0.

This project uses OpenTelemetry tracing/logging and exports them to Elasticsearch via an open telemetry collector. Docker compose file to spin up an Otel collector, Elasticsearch and Kibana instance on docker desktop for development environment is in dockercompose-observability folder.

OpenTelemetry documents provide an excellent starting point on how to add OpenTelemetry supoort to a .Net project.

Setup

  1. Start up a Postgresql instance with logical replication enabled. Such a docker container can be started with following command:
docker run -dt --restart unless-stopped -d -p 5432:5432 --name=postgres15.1 -e POSTGRES_PASSWORD=password postgres:15.1 -c 'wal_level=logical'
  1. Script for creating Postgresql Db tables and setting up logical replication used in this project.

  2. Dapr configuration files are in components folder. Projects are configured to use these files on startup by Dapr Sidekick configuration.

  3. Rabbitmq is used as Dapr pubsub component. A docker container running Rabbitmq with management support can be started with following command:

docker run -dt --restart unless-stopped -d -p 5672:5672 -p 15672:15672 --hostname my-rabbit --name rabbitmq3 rabbitmq:3-management

Rabbitmq user/password used by Dapr is configured in "host" parameter value in dapr pubsub.yaml configuration file. A user/password pair with these values can be created via RabbitMq management.

More References

  1. Push-based Outbox Pattern with Postgres Logical Replication

About

Dapr enabled Microsoft Orleans services utilizing outbox pattern implementation with Postgres Logical Replication for communicating over Dapr pub/sub.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages