2023-11-19 04:29:28 +01:00
|
|
|
# ProSol.Messaging
|
2023-11-16 06:04:03 +01:00
|
|
|
|
2023-11-21 09:08:50 +01:00
|
|
|
Implements a message broker with ability to build a pipeline of listeners.
|
2023-12-08 04:33:55 +01:00
|
|
|
|
|
|
|
For example, let's make a pipeline which detects future and past dates:
|
|
|
|
|
|
|
|
Add package:
|
|
|
|
```sh
|
|
|
|
dotnet add package ProSol.Messaging --version 4.0
|
|
|
|
```
|
|
|
|
|
|
|
|
```csharp
|
|
|
|
using ProSol.Messaging;
|
|
|
|
using ProSol.Messaging.Filtering;
|
|
|
|
using ProSol.Messaging.Acting;
|
|
|
|
|
|
|
|
var provider = new PipelineMessagePublisher<DateTime>();
|
|
|
|
|
|
|
|
provider
|
|
|
|
.Endpoint(x => x >= DateTime.Now)
|
|
|
|
.Act(x => Console.WriteLine($"Future: {x}"));
|
|
|
|
|
|
|
|
provider
|
|
|
|
.Act(x => Console.WriteLine($"Past: {x}"));
|
|
|
|
|
|
|
|
provider.Publish(DateTime.Today.AddDays(1));
|
|
|
|
provider.Publish(DateTime.Today.AddDays(-1));
|
|
|
|
```
|
|
|
|
|
|
|
|
Try this and you will see two messages in the console, with dates, depending on your current time:
|
|
|
|
```
|
|
|
|
Future: ...
|
|
|
|
Past: ...
|
|
|
|
```
|
|
|
|
|
|
|
|
That's it! It's basically a pipeline builder for dispatching the messages.
|
|
|
|
|
|
|
|
There are some more extension methods for dispatching, you may find there:
|
2023-12-08 00:31:37 +01:00
|
|
|
- observer-related interfaces [here](/src/Contracts/).
|
|
|
|
- `PipelineMessagePublisher` [here](/src/Publishers/PipelineMessagePublisher.cs).
|
|
|
|
- [Translating](/docs/Translating.md) for messages.
|
2023-12-08 04:33:55 +01:00
|
|
|
- [Filtering](/docs/Filtering.md) for messages.
|
|
|
|
|
|
|
|
Happy coding!
|