An async, fast and slim message bus for transparent inproc / outbound messaging
It has
- no queue!
- fully async processing
- parallelization => every consumer runs it's own task/thread!
- transparent client / server functionality
- immutable records as messages
- no serialization if a message stays on one side!
- advanced filtering of requests or repsonses
- Add support for net 8, net9, net10
- Chg Xunit async void (deprecated) to async Task support
private async Task SubscriberFunc(MyMessage message) {
//do sth with your message while running on your own task/thread
}
await _messageBus.Subscribe<MyMessage>(SubscriberFunc);private async Task<MyResponse> SubscriberFunc(MyRequest message) {
//do sth with your message while running on your own task/thread
return new MyResponse(someResult);
}
await _messageBus.Subscribe<MyRequest, MyResponse>(SubscriberFunc);await _messageBus.Publish(new MyMessage());As many can subscribe to the same messages you can get multiple responses.
MyResponse[] responses = await _messageBus.GetResponses<MyResponse>(new MyRequest());public record MyMessage : MessageBase {
public string OneOfMyProps { get; init; }
}public record MyRequest : RequestBase {
public string OneOfMyProps { get; init; }
}public record MyResponse : ResponseBase {
public string OneOfMyProps { get; init; }
}public record MyRequest : RequestBase<MyResponse> {
public string OneOfMyProps { get; init; }
}
public record MyResponse : ResponseBase<MyRequest> {
public string OneOfMyProps { get; init; }
}diContainerBuilder.AddNoQMessageBus(); //or servicecollection
//after building the container:
diContainer.Resolve<IMessageBusConfig>().StartLocalNoQMessageBus();
//from now on you can use:
_messageBus = diContainer.Resolve<IMessageBus>();diContainerBuilder.AddNoQMessageBus(); //or servicecollection
diContainerBuilder.AddNoQSignalRHost(); //or servicecollection
//after building the container:
await diContainer.StartNoQSignalRHost(x => x.UseUrl("http://localhost:5001"));
//from now on you can use:
_messageBus = diContainer.Resolve<IMessageBus>();diContainerBuilder.AddNoQMessageBus(); //or servicecollection
diContainerBuilder.AddNoQSignalRClient(); //or servicecollection
//after building the container:
await diContainer.StartNoQSignalRClient(x => x.UseUrl("http://localhost:5001"));
//from now on you can use:
_messageBus = diContainer.Resolve<IMessageBus>();