Skip to content

Commit 7881af4

Browse files
committed
doc
1 parent 11aae41 commit 7881af4

4 files changed

Lines changed: 90 additions & 18 deletions

File tree

Ev.ServiceBus.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{15791C07-7
2424
docs\Ev.ServiceBus.HealthChecks.md = docs\Ev.ServiceBus.HealthChecks.md
2525
docs\Ev.ServiceBus.Mvc.md = docs\Ev.ServiceBus.Mvc.md
2626
docs\Instrumentation.md = docs\Instrumentation.md
27+
docs\Isolation.md = docs\Isolation.md
2728
EndProjectSection
2829
EndProject
2930
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8EC286EB-A71F-4431-ACA4-E92C79975817}"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ across the whole system (name of the property : `PayloadTypeId`).
4040
* [Initial Set up](./docs/SetUp.md)
4141
* [How to send messages](./docs/SendMessages.md)
4242
* [How to receive messages](./docs/ReceiveMessages.md)
43+
* [Isolation Feature](./docs/Isolation.md)
4344
* [Advanced scenarios](./docs/AdvancedScenarios.md)
4445
* [Ev.ServiceBus.HealthChecks](./docs/Ev.ServiceBus.HealthChecks.md)
4546
* [Instrumentation](./docs/Instrumentation.md)

docs/AdvancedScenarios.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,21 +201,3 @@ public class MyMessageSender
201201
}
202202
}
203203
```
204-
205-
## Running service instance in isolation
206-
207-
By "running in isolation" we mean ability to run an instance of microservice (MS) on local environment, when MS is using real queues and topics to communicate with other MSs
208-
Simple case : App1 sending message to App2, which responds back with another message.
209-
Desired isolation is in the following: If message comes from App1.Local, then the response to it should be processed also only by App1.Local. Same holds true from App1.Cloud - it should process responses that are only coming from cloud instances.
210-
211-
This is achived by simply proper condifuration (see sample project)
212-
```csharp
213-
services.AddServiceBus(
214-
settings =>
215-
{
216-
// Provide a connection string here !
217-
settings.WithConnection("Endpoint=sb://yourconnection.servicebus.windows.net/;SharedAccessKeyName=yourkeyh;SharedAccessKey=ae6pTuOBAFDH2y7xJJf9BFubZGxXMToN6B9NiVgLnbQ=", new ServiceBusClientOptions());
218-
settings.UseIsolation = true;
219-
settings.IsolationKey = "your-isolation-key";
220-
})
221-
```

docs/Isolation.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Isolation feature
2+
3+
## Concept
4+
5+
In a microservice ecosystem where those services communicate through messages via Service bus queues or topics, some scenarios become difficult to debug.
6+
For example, sometimes you want to manually send a message to a queue and debug in local how your microservice behaves. That would require you to recreate a service bus namespace with the proper queue configured and link app running in local to it.
7+
Another example is, sometimes you want to send a message to one microservice to see and debug how another microservice behaves down the line.
8+
9+
The isolation feature allows your local application to connect to the service bus namespace of an up and running environment without disturbing it's stability.
10+
It then allows you to manually send messages with some metadata to that queue and you local application will receive it instead of the app running in the environment.
11+
12+
## Configuration
13+
14+
### Default configuration
15+
By default, the isolation feature is disabled. your application will treat every incoming messages.
16+
```csharp
17+
services.AddServiceBus(
18+
settings =>
19+
{
20+
// Provide a connection string here !
21+
settings.WithConnection("Endpoint=sb://yourconnection.servicebus.windows.net/;SharedAccessKeyName=yourkeyh;SharedAccessKey=ae6pTuOBAFDH2y7xJJf9BFubZGxXMToN6B9NiVgLnbQ=", new ServiceBusClientOptions());
22+
settings.WithIsolation(IsolationBehavior.HandleAllMessages, null, null);
23+
})
24+
```
25+
26+
### Environment configuration
27+
To use the feature, you need to activate isolation both on your local app and on your environment.
28+
29+
Applications running in your environment must use the "HandleNonIsolatedMessages" behavior.
30+
You also need to provide a name for your microservice.
31+
32+
```csharp
33+
services.AddServiceBus(
34+
settings =>
35+
{
36+
// Provide a connection string here !
37+
settings.WithConnection("Endpoint=sb://yourconnection.servicebus.windows.net/;SharedAccessKeyName=yourkeyh;SharedAccessKey=ae6pTuOBAFDH2y7xJJf9BFubZGxXMToN6B9NiVgLnbQ=", new ServiceBusClientOptions());
38+
settings.WithIsolation(IsolationBehavior.HandleNonIsolatedMessages, null, "My.Application");
39+
})
40+
```
41+
42+
### Local configuration
43+
To use the feature, you need to activate isolation both on your local app and on your environment.
44+
45+
The Application running in local must use the "HandleIsolatedMessage" behavior.
46+
You also need to provide a name for your microservice and an isolation key.
47+
Your local application will only process messages that have the same isolation key as the one you provide.
48+
49+
```csharp
50+
services.AddServiceBus(
51+
settings =>
52+
{
53+
// Provide a connection string here !
54+
settings.WithConnection("Endpoint=sb://yourconnection.servicebus.windows.net/;SharedAccessKeyName=yourkeyh;SharedAccessKey=ae6pTuOBAFDH2y7xJJf9BFubZGxXMToN6B9NiVgLnbQ=", new ServiceBusClientOptions());
55+
settings.WithIsolation(IsolationBehavior.HandleIsolatedMessage, "My.IsolationKey", "My.Application");
56+
})
57+
```
58+
59+
## Usage
60+
61+
### Simple case
62+
Now to use the feature, you will need to send a message with the proper metadata to the queue/topic of your environment.
63+
64+
Let's say you have a microservice `App1` and you want to run that application on local for debugging purposes.
65+
You will need to send a message to the queue/topic of `App1` with the following metadata:
66+
```json
67+
{
68+
"IsolationKey": "My.IsolationKey",
69+
"ApplicationName": "App1"
70+
}
71+
```
72+
Your local app will receive the message and process it.
73+
74+
### Complex case
75+
Now let's say that in your environment you have the following microservices: `App1`, `App2`, `App3`, `App4`, `App5`.
76+
They communicate with each other through messages.
77+
The entry point of your ecosystem is `App1`, but you want to debug `App2` and `App3` locally.
78+
79+
You will need to send a message to the queue/topic of `App1` with the following metadata:
80+
```json
81+
{
82+
"IsolationKey": "My.IsolationKey",
83+
"ApplicationName": "App2,App3"
84+
}
85+
```
86+
The isolation metadata will be transferred to any message sent during the processing of the isolated message.
87+
88+
Meaning that your local apps will be able to receive subsequent isolated messages allowing you to debug them.

0 commit comments

Comments
 (0)