Skip to content

Commit 7f4ced9

Browse files
committed
dockerized the apps
1 parent 4e2cace commit 7f4ced9

21 files changed

+327
-40
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,6 @@ Run docker command below from the `src` folder in a CLI
2929
docker compose -f docker-compose-base.yml -f compose-azure.yml --env-file asb.env up -d
3030
```
3131

32-
## Running the code
32+
## [Running the Sample](docs.md#Running-the-sample)
3333

34-
> [!WARNING]
35-
> When using Visual Studio, make sure you have "Enable Multi-Project Launch profiles" setting on. Allow Visual Studio 2024 "multi-launch" so you can easily select the profile you want to run.
36-
>
37-
> It can be activated by accessing the Tools menu -> Manage preview features- Enable Multi-Project Launch profiles.
38-
39-
After opening the solutions (from Visual Studio or Rider), choose one of the run profiles that matches the transport configured previously:
40-
41-
- `RabbitMQ`
42-
- `Azure Service Bus`
43-
44-
Run the solution to start the demo.
45-
46-
Navigate to http://localhost:9090/ to see the UI
47-
## High-level solution overview
48-
49-
The sample consists of 4 console applications hosting MassTransit message producers and consumers that implement a simplified order processing logic from an e-commerce system.
50-
51-
![System Overview](diagram.svg "width=680")
34+
## [Read more about how it works](docs.md#Walkthrough)
21.9 KB
Loading

β€Ždocs.mdβ€Ž

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
This sample shows the usage of the Particular Service Platform with an existing MassTransit system.
2+
3+
> [!NOTE]
4+
> This sample uses RabbitMQ as the messaging infrastructure. Refer to [the setup documentation](https://docs.particular.net/servicecontrol/masstransit/#settings) for Azure Service Bus setup instructions.
5+
6+
## Walkthrough
7+
8+
The sample consists of 4 applications hosting MassTransit message producers and consumers that implement a simplified order processing logic from an e-commerce system.
9+
10+
![System Overview](diagram.svg "width=680")
11+
12+
`ClientUI` application generates `PlaceOder` messages at continuous rate that trigger follow-up message flow in the other parts of the system.
13+
14+
### Experiencing failures
15+
16+
In the UI, press the `Run scenario` button.
17+
18+
All consumers provide ability to change message processing failure rate by pressing <kbd>I</kbd> to increase and <kbd>D</kbd> to decrease it. Each consumer application shows a list of available commands and a summary of currently used configuration values.
19+
20+
````
21+
22+
For example, whenever the `Billing` consumer fails to process a message, a log entry gets printed to the command line window, and the message is moved to the `bill-order_error` queue.
23+
24+
```code
25+
fail: MassTransit.ReceiveTransport[0]
26+
R-FAULT rabbitmq://localhost/bill-order b4950300-b188-ac74-36f6-08dcf7ec3b26 Messages.OrderPlaced Billing.BillOrderConsumer(00:00:00.2819272)
27+
System.Exception: BOOM. A failure occurred
28+
at Billing.SimulationEffects.SimulatedMessageProcessing(CancellationToken cancellationToken) in C:\git\p\docs-mt-fork\strategy-527.docs.particular.net\samples\servicecontrol\masstransit-recoverability\ServiceControl_5\Billing\SimulationEffects.cs:line 17
29+
at Billing.BillOrderConsumer.Consume(ConsumeContext`1 context) in C:\git\p\docs-mt-fork\strategy-527.docs.particular.net\samples\servicecontrol\masstransit-recoverability\ServiceControl_5\Billing\Consumers\BillOrderConsumer.cs:line 12
30+
at MassTransit.DependencyInjection.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next) in /_/src/MassTransit/DependencyInjection/DependencyInjection/ScopeConsumerFactory.cs:line 22
31+
at MassTransit.DependencyInjection.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next) in /_/src/MassTransit/DependencyInjection/DependencyInjection/ScopeConsumerFactory.cs:line 22
32+
at MassTransit.Middleware.ConsumerMessageFilter`2.MassTransit.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next) in /_/src/MassTransit/Middleware/ConsumerMessageFilter.cs:line 48
33+
````
34+
35+
### Handling failures with the Particular Platform
36+
37+
#### Running the sample
38+
39+
In order, to see how the Particular Platfrom improves the failed messages management, start the containers responsible for running the platform:
40+
41+
### **RabbitMQ**
42+
43+
> [!NOTE]
44+
> The RabbitMQ Broker is started as part of the docker compose process
45+
46+
Run docker command below from the `src` folder in a CLI
47+
48+
```cmd
49+
docker compose -f docker-compose-base.yml -f compose-rabbitmq.yml --env-file rabbit.env up -d
50+
```
51+
52+
## **Azure ServiceBus**
53+
54+
Configure the access to your Azure Service Bus namespace by editing the variables in `src/asb.env`
55+
56+
```env
57+
CONNECTIONSTRING="Endpoint=sb://[NAMESPACE].servicebus.windows.net/;SharedAccessKeyName=[KEYNAME];SharedAccessKey=[KEY]"
58+
```
59+
60+
Run docker command below from the `src` folder in a CLI
61+
62+
```cmd
63+
docker compose -f docker-compose-base.yml -f compose-azure.yml --env-file asb.env up -d
64+
```
65+
66+
This will make the platform monitor error messages for all the consumers in the sample system. Upon failure any moved by a MassTransit consumer to an error queue will be ingest and index by the platform.
67+
68+
#### Inspecting failures
69+
70+
Navigate to [http://localhost:9090](http://localhost:9090), or click the `View in ServicePulse` button to see the details on the failures ingested by the platform.
71+
72+
![Service Pulse Dashboard](service-pulse-dashboard-failed-messages.png "Message processing errors summary view")
73+
74+
#### Scheduling message reprocessing
75+
76+
Click on the "Failed Messages" button at the top of the page to see all failed messages ingested by the platform grouped by the exception trype and stack trace.
77+
78+
![Service Pulse Failed Messages](service-pulse-dashboard-failed-messages-groups.png "Failed messages grouping")
79+
80+
Drilling into an existing group to see the list of individual processing failures. Clicking on any
81+
of the rows in the list shows detailed information on a given failed message in the headers and message body tabs.
82+
83+
A failed message can be scheduled for reprocessing by clicking the `Retry message` button.
84+
85+
![Service Pulse Failed Message View](service-pulse-failed-message-view.png "Failed message details view")
86+
87+
#### Editing messages before reprocessing
88+
89+
Go to the details page for one of the failed messages and click the `Edit & retry` button at the top. The pop-up window shows the headers collection and the message body in two separate tabs.
90+
91+
Navigate to the `Message Body` tab, change the last digit of the `orderId` value, and click "Retry" to schedule the message for reprocessing.
92+
93+
![Edit Message View](service-pulse-edit-before-retry.png "Edit & Retry view showing the message body")
99.4 KB
Loading
117 KB
Loading

β€Žsample.mdβ€Ž

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
title: ServiceControl recoverability for MassTransit
3+
summary: Sample presenting a system that uses MassTransit together with the Particular Service Platform
4+
reviewed: 2024-09-04
5+
component: ServiceControl
6+
---
7+
8+
This sample shows the usage of the Particular Service Platform with an existing MassTransit system.
9+
10+
>[!NOTE]
11+
>This sample uses RabbitMQ as the messaging infrastructure. Refer to [the setup documentation](/servicecontrol/masstransit/#settings) for Amazon SQS and Azure Service Bus setup instructions.
12+
13+
## Download the sample
14+
15+
The sample doesn't require a message queue or database to install - only a compatible IDE. To get started:
16+
17+
downloadbutton
18+
19+
## Run the sample
20+
21+
Running the sample requires two steps:
22+
23+
1. Execute `docker compose up -d` in the root directory of the sample to start the RabbitMQ broker
24+
2. Open the `MassTransitShowcaseDemo.sln` solution and start `ClientUI`, `Billing`, `Sales`, and `Shipping` projects.
25+
26+
## Walkthrough
27+
28+
The sample consists of 4 console applications hosting MassTransit message producers and consumers that implement a simplified order processing logic from an e-commerce system.
29+
30+
![System Overview](diagram.svg "width=680")
31+
32+
`ClientUI` application generates `PlaceOder` messages at continuous rate that trigger follow-up message flow in the other parts of the system.
33+
34+
### Experiencing failures
35+
36+
All consumers provide ability to change message processing failure rate by pressing <kbd>I</kbd> to increase and <kbd>D</kbd> to decrease it. Each consumer application shows a list of available commands and a summary of currently used configuration values.
37+
38+
The initial value for the failure rate for each each endpoint is `0`, except for the `Billing` for which the value is `50`%:
39+
40+
```code
41+
Billing Endpoint
42+
Press I to increase the simulated failure rate
43+
Press D to decrease the simulated failure rate
44+
Press R to reset simulation
45+
Press CTRL+C to quit
46+
47+
Failure rate: 50%
48+
```
49+
50+
Whenever the `Billing` consumer fails to process a message, a log entry gets printed to the command line window, and the message is moved to the `BillOrder_error` queue.
51+
52+
```code
53+
fail: MassTransit.ReceiveTransport[0]
54+
R-FAULT rabbitmq://localhost/BillOrder b4950300-b188-ac74-36f6-08dcf7ec3b26 Messages.OrderPlaced Billing.BillOrderConsumer(00:00:00.2819272)
55+
System.Exception: BOOM. A failure occurred
56+
at Billing.SimulationEffects.SimulatedMessageProcessing(CancellationToken cancellationToken) in C:\git\p\docs-mt-fork\strategy-527.docs.particular.net\samples\servicecontrol\masstransit-recoverability\ServiceControl_5\Billing\SimulationEffects.cs:line 17
57+
at Billing.BillOrderConsumer.Consume(ConsumeContext`1 context) in C:\git\p\docs-mt-fork\strategy-527.docs.particular.net\samples\servicecontrol\masstransit-recoverability\ServiceControl_5\Billing\Consumers\BillOrderConsumer.cs:line 12
58+
at MassTransit.DependencyInjection.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next) in /_/src/MassTransit/DependencyInjection/DependencyInjection/ScopeConsumerFactory.cs:line 22
59+
at MassTransit.DependencyInjection.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next) in /_/src/MassTransit/DependencyInjection/DependencyInjection/ScopeConsumerFactory.cs:line 22
60+
at MassTransit.Middleware.ConsumerMessageFilter`2.MassTransit.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next) in /_/src/MassTransit/Middleware/ConsumerMessageFilter.cs:line 48
61+
```
62+
63+
### Handling failures using native tools
64+
65+
Failed messages can be accessed using RabbitMQ Management console. Navigate to [queue list](http://localhost:15672/#/queues) (use `guest` for username and password) and click on the corresponding row to see summary information for the the `BillOrder_error` queue.
66+
67+
![RabbitMQ Error Queue Overview](rabbit-management-error-queue.png "RabbitMQ Management Console error queue overiview")
68+
69+
For any individal error queue, the built-in tooling enables:
70+
- peeking failed messages from the head of the queue,
71+
- moving all messages in the error queue to some other location
72+
73+
![RabbitMQ Error Message Managment](rabbit-management-error-message-management.png "Managing error messages in RabbitMQ Management Console")
74+
75+
### Handling failures with the Particular Platform
76+
77+
#### Starting the platform
78+
79+
In order, to see how the Particular Platfrom improves the failed messages management, start the containers responsible for running the platform:
80+
81+
```bash
82+
docker compose --profile platform up -d
83+
```
84+
85+
This will make the platform monitor error messages for all the consumers in the sample system. Upon failure any moved by a MassTransit consumer to an error queue will be ingest and index by the platform.
86+
87+
#### Inspecting failures
88+
89+
Navigate to [http://localhost:9090](http://localhost:9090) to see the details on the failures ingested by the platform.
90+
91+
![Service Pulse Dashboard](service-pulse-dashboard-failed-messages.png "Message processing errors summary view")
92+
93+
#### Scheduing message reprocessing
94+
95+
Click on the "Failed Messages" button at the top of the page to see all failed messages ingested by the platform grouped by the exception trype and stack trace.
96+
97+
![Service Pulse Failed Messages](service-pulse-dashboard-failed-messages-groups.png "Failed messages grouping")
98+
99+
Drilling into an existing group to see the list of individual processing failures. Clicking on any
100+
of the rows in the list shows detailed information on a given failed message in the headers and message body tabs.
101+
102+
A failed message can be scheduled for reprocessing by clicking the `Retry message` button.
103+
104+
![Service Pulse Failed Message View](service-pulse-failed-message-view.png "Failed message details view")
105+
106+
When messages get moved back to the input queue of the consumer and successfully reprocessed, this is indicated by a green rectangle (🟩) in the console output.
107+
108+
![Billing Service Console Output](billing-console-reprocessing-output.png "Console output showing sucessful message reprocessing")
109+
110+
#### Editing messages before reprocessing
111+
112+
Go to the details page for one of the failed messages and click the `Edit & retry` button at the top. The pop-up window shows the headers collection and the message body in two separate tabs.
113+
114+
Navigate to the `Message Body` tab, change the last digit of the `orderId` value, and click "Retry" to schedule the message for reprocessing.
115+
116+
![Edit Message View](service-pulse-edit-before-retry.png "Edit & Retry view showing the message body")
127 KB
Loading
145 KB
Loading
148 KB
Loading
283 KB
Loading

0 commit comments

Comments
Β (0)