This repository contains usage examples of the MassTransit SQL transport for parallel processing of partitioned message sequences. The five instances of the Consumer application process incoming messages according to specified receive mode, while the Sender application generates them. The resulting traces can be viewed in Jaeger.
- Start Jaeger and PostgreSQL by running the following command:
docker compose up -d jaeger database
- Run 5 instances of the consumer application by executing:
docker compose up --build consumer
- Once the consumer's instances are up and running, start the sender application by executing:
docker compose up --build sender
- View the traces in Jaeger at http://localhost:16686/
This example demonstrates how messages are partitioned based on their partition keys and processed in order, without overlapping.
- Open
Example.Consumer/Program.cs
and set the receive mode toSqlReceiveMode.PartitionedOrdered
(line 36). Restart the consumer and sender applications. - In Jaeger, select
Sender
in the "Service" dropdown. You will see the "Sender: SendMessages" trace. Click on it for full details. Typepartitionkey=2
in the search field in the navbar and press the locate button. - Observe the cyan bars: they do not overlap, indicating that messages in one partition (partition 2 in this case) are processed in order.
This example demonstrates how messages are processed in parallel, without any partition and order.
- Open
Example.Consumer/Program.cs
and set the receive mode toSqlReceiveMode.Normal
(line 36). Restart the consumer and sender applications. - In Jaeger, select
Sender
in the "Service" dropdown. You will see the "Sender: SendMessages" trace. Click on it for full details. Typepartitionkey=2
in the search field in the navbar and press the locate button. - Observe the cyan bars: they overlap, indicating that messages are processed in parallel without any specific order.
Reset the environment to its initial state, by executing:
docker compose down