Skip to content

Commit

Permalink
Add example to Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyRaga committed Jun 18, 2023
1 parent aa5fe14 commit 92e5479
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,32 @@ ecosystem.

- [KafkaFlow.Contrib.ProcessManagers.Postgres](./src/KafkaFlow.Contrib.ProcessManagers.Postgres) -
Postgres SQL backend for storing process' state

## Usage example

Here is how process managers and outbox can be used together:

```csharp
services
// We need an NpgsqlDataSource shared between Outbox and Process Managers
// to be able to update state and send messages transactionally
.AddSingleton(myNpgsqlDataSource)
.AddPostgresProcessManagerState()
.AddPostgresOutboxBackend()
.AddKafka(kafka =>
kafka
.AddCluster(cluster =>
cluster
// The dispatcher service will be started in background
.AddOutboxDispatcher(dispatcher =>
// I strongly recommend to use Murmur2Random since it is
// the "original" default in Java ecosystem, and is shared by other
// ecosystems, like JavaScript or Python.
dispatcher.WithPartitioner(Partitioner.Murmur2Random))
.AddProducer("default", producer =>
producer
// Make this producer go through the outbox
.WithOutbox()
.AddMiddlewares(m => m.AddSerializer<JsonCoreSerializer>()))
// and so on
```

0 comments on commit 92e5479

Please sign in to comment.