Pemvedr.Common.Bus.Bootstrapper 0.1.20241030.1
#«Pemvedr.Common.Bus.Bootstrapper»
Structure
Examples
Create message, here a command.
public class ProcessEntry : Command
{
public ProcessEntry(AddEntry logEntry) : base(logEntry.Created, RetryPolicy.Factory.DefaultRetries())
{
LogEntry = logEntry;
}
public AddEntry LogEntry { get; }
}
Create a handler for the message
public class AddEntryHandler : CommandHandler<ProcessEntry>
{
private readonly ILog _log;
public AddEntryHandler(ILog log, ....)
{
_log = log.For(this);
}
public override Task Handle(ProcessEntry message)
{
...
}
}
Create a module which returns the handler
public class AddEntryModule : IBusModule
{
public IReadOnlyCollection<ICommandHandler> GetCommandHandlers(IIocContainer container) => new ICommandHandler[]{ container.Get<AddEntryHandler>() };
public IReadOnlyCollection<IEventHandler> GetEventHandlers(IIocContainer container) => new IEventHandler[0];
public IReadOnlyCollection<Saga> GetSagas(IIocContainer container) => new Saga[0];
}
Optional: Register classes in Startup
public void ConfigureServices(IServiceCollection services) =>
services
.AddTransient<IBusModule, AddEntryModule>()
.AddSingleton<IBus, SimpleBusBootstrapper>();
Send messages to the bus
public class EntryReceiver
{
private readonly IBus _bus;
public EntryReceiver(IBus bus)
{
_bus = bus;
}
public async Task ProcessEntry(AddEntry logEntry)
{
await _bus.Send(new ProcessEntry(logEntry));
}
}
Development hints
none
See also
none
No packages depend on Pemvedr.Common.Bus.Bootstrapper.
.NET 8.0
- Pemvedr.Common.Bus.SimpleInMemory (>= 0.2.20241030.1)
- Pemvedr.Common.Bus (>= 0.2.20241030.1)
- Pemvedr.Common.EventlogBusIoc (>= 0.2.20241030.1)
| Version | Downloads | Last updated |
|---|---|---|
| 0.1.20241101.1 | 10 | 11/01/2024 |
| 0.1.20241031.2 | 6 | 10/31/2024 |
| 0.1.20241031.1 | 7 | 10/31/2024 |
| 0.1.20241030.1 | 8 | 10/30/2024 |
| 0.1.20240903.1 | 9 | 09/02/2024 |
| 0.1.20240629.1 | 6 | 06/29/2024 |
| 0.1.20240401.1 | 7 | 04/01/2024 |
| 0.1.20230304.9 | 8 | 03/04/2023 |
| 0.1.20220327.1 | 11 | 05/15/2022 |
| 0.1.20220105.1 | 10 | 05/15/2022 |
| 0.1.20210524.2 | 7 | 05/15/2022 |
| 0.1.20210428.1 | 6 | 05/15/2022 |
| 0.1.20201105.3 | 7 | 05/15/2022 |