Skip to content

Commit f8ba65b

Browse files
authored
Merge branch 'main' into udidahan-patch-1
2 parents 50580eb + 466dc20 commit f8ba65b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+541
-110
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Code Analysis
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
- release-*
8+
workflow_dispatch:
9+
jobs:
10+
code-analysis:
11+
uses: particular/shared-workflows/.github/workflows/code-analysis.yml@main

.github/workflows/nuget-audit.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ on:
44
env:
55
DOTNET_NOLOGO: true
66
jobs:
7-
build:
8-
name: Linux
9-
runs-on: ubuntu-22.04
10-
steps:
11-
- name: Checkout
12-
uses: actions/[email protected]
13-
- name: Setup .NET SDK
14-
uses: actions/[email protected]
15-
with:
16-
global-json-file: global.json
17-
- name: Restore
18-
id: restore
19-
run: dotnet restore src
7+
call-shared-nuget-audit:
8+
uses: particular/shared-workflows/.github/workflows/nuget-audit.yml@main
9+
secrets: inherit

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Run docker command below from the `src` folder in a CLI
3434
docker compose -f docker-compose-base.yml -f compose-azure.yml --env-file asb.env up -d
3535
```
3636

37-
## Running the code
37+
## [Running the Sample](docs.md#Running-the-sample)
3838

3939
> [!WARNING]
4040
> 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.
21.9 KB
Loading

docs.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
This samples shows how the errors in an existing MassTransit system can be managed using the Particular Service Platform.
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 processes 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 `PlaceOrder` messages that trigger follow-up message flows in the other parts of the system.
13+
14+
### Experiencing failures
15+
16+
In the UI, press the `Run scenario` button. This will generate a set of `PlaceOrder` messages, configured to fail at different consumers through the showcase.
17+
For example, whenever the `Billing` consumer fails to process a message, the message is moved to the `bill-order_error` queue.
18+
19+
```code
20+
fail: MassTransit.ReceiveTransport[0]
21+
R-FAULT rabbitmq://localhost/bill-order b4950300-b188-ac74-36f6-08dcf7ec3b26 Messages.OrderPlaced Billing.BillOrderConsumer(00:00:00.2819272)
22+
System.Exception: BOOM. A failure occurred
23+
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
24+
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
25+
at MassTransit.DependencyInjection.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next) in /_/src/MassTransit/DependencyInjection/DependencyInjection/ScopeConsumerFactory.cs:line 22
26+
at MassTransit.DependencyInjection.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next) in /_/src/MassTransit/DependencyInjection/DependencyInjection/ScopeConsumerFactory.cs:line 22
27+
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
28+
```
29+
30+
### Handling failures with the Particular Platform
31+
32+
#### Running the sample
33+
34+
To see how the Particular Platfrom improves failed message management, start the containers responsible for running the platform:
35+
36+
### **RabbitMQ**
37+
38+
> [!NOTE]
39+
> The RabbitMQ Broker is started as part of the docker compose process
40+
41+
Run docker command below from the `src` folder in a CLI
42+
43+
```cmd
44+
docker compose -f docker-compose-base.yml -f compose-rabbitmq.yml --env-file rabbit.env up -d
45+
```
46+
47+
## **Azure ServiceBus**
48+
49+
Configure the access to your Azure Service Bus namespace by editing the variables in `src/asb.env`
50+
51+
```env
52+
CONNECTIONSTRING="Endpoint=sb://[NAMESPACE].servicebus.windows.net/;SharedAccessKeyName=[KEYNAME];SharedAccessKey=[KEY]"
53+
```
54+
55+
Run docker command below from the `src` folder in a CLI
56+
57+
```cmd
58+
docker compose -f docker-compose-base.yml -f compose-azure.yml --env-file asb.env up -d
59+
```
60+
61+
This will make the platform monitor error messages for all the consumers in the sample system. Upon failure, any message moved by a MassTransit consumer to an error queue will be ingested by the platform.
62+
63+
#### Inspecting failures
64+
65+
Navigate to [http://localhost:9090](http://localhost:9090), or click the `View in ServicePulse` button to see the details on failures ingested by the platform.
66+
67+
![Service Pulse Dashboard](service-pulse-dashboard-failed-messages.png "Message processing errors summary view")
68+
69+
#### Scheduling message reprocessing
70+
71+
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 type and stack trace.
72+
73+
![Service Pulse Failed Messages](service-pulse-dashboard-failed-messages-groups.png "Failed messages grouping")
74+
75+
Drill into an existing group to see the list of individual processing failures. Clicking on any of the rows in the list shows detailed information of a given failed message in the headers and message body tabs.
76+
77+
A failed message can be scheduled for reprocessing by clicking the `Retry message` button.
78+
79+
![Service Pulse Failed Message View](service-pulse-failed-message-view.png "Failed message details view")
80+
81+
#### Editing messages before reprocessing
82+
83+
Go to the details page for one of the failed messages and click the `Edit & retry` button. The pop-up window shows the headers collection and the message body in two separate tabs.
84+
85+
Navigate to the `Message Body` tab, change the last digit of the `orderId` value, and click "Retry" to schedule the message for reprocessing.
86+
87+
> [!WARNING]
88+
> Changing or deleting header values may change or cause issues with the subsequent re-processing. It is recommended that these values are not changed if you are unsure of their purpose.
89+
90+
![Edit Message View](service-pulse-edit-before-retry.png "Edit & Retry view showing the message body")
99.4 KB
Loading

rabbit-management-error-queue.png

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+
#### Scheduling 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

0 commit comments

Comments
 (0)