- Notifications
You must be signed in to change notification settings - Fork7
Fast multi-transport messaging framework
License
NotificationsYou must be signed in to change notification settings
BookBeat/knightbus
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
KnightBus is a fast, lightweight and extensible messaging framework that supports multiple active message transports
Find the official KnightBus documentation here
Package | NuGet |
---|---|
KnightBus.ApplicationInsights | |
KnightBus.NewRelic |
Package | NuGet |
---|---|
KnightBus.ProtobufNet | |
KnightBus.Newtonsoft | |
KnightBus.MessagePack |
Package | NuGet |
---|---|
KnightBus.Host | |
KnightBus.Core | |
KnightBus.Core.Management | |
KnightBus.Messages | |
KnightBus.SqlServer | |
KnightBus.Schedule |
publicclassCommandProcessor:IProcessCommand<SampleCommand,SampleSettings>,{publicCommandProcessor(ISomeDependencydependency){//You can use your own container for dependency injection}publicTaskProcessAsync(SampleCommandmessage,CancellationTokencancellationToken){//Your code goes herereturnTask.CompletedTask;}}
classProgram{staticasyncTaskMain(string[]args){varhost=Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args).ConfigureServices(services=>{//Multiple active transportsservices.UseServiceBus(config=>config.ConnectionString="sb-connection").UseTransport<ServiceBusTransport>().UseBlobStorage(config=>config.ConnectionString="storage-connection").UseTransport<StorageTransport>().RegisterProcessors();}).UseKnightBus().Build();awaithost.StartAsync(CancellationToken.None);}}
KnightBus supports inserting your own middleware into the execution pipeline.
publicclassCustomThrottlingMiddleware:IMessageProcessorMiddleware{privatereadonlySemaphoreQueue_semaphoreQueue;publicintCurrentCount=>_semaphoreQueue.CurrentCount;publicCustomThrottlingMiddleware(intmaxConcurrent){_semaphoreQueue=newSemaphoreQueue(maxConcurrent);}publicasyncTaskProcessAsync<T>(IMessageStateHandler<T>messageStateHandler,IPipelineInformationpipelineInformation,IMessageProcessornext,CancellationTokencancellationToken)whereT:class,IMessage{try{await_semaphoreQueue.WaitAsync().ConfigureAwait(false);awaitnext.ProcessAsync(messageStateHandler,cancellationToken).ConfigureAwait(false);}finally{_semaphoreQueue.Release();}}}
KnightBus supports custom plugins. Examples of existing plugins are: TcpAliveListener (K8S liveness probes) and Scheduling (Chron triggers).
publicclassCustomPlugin:IPlugin{publicCustomPlugin(ISomeDependencydependency,ILogger<CustomPlugin>logger){}publicasyncTaskStartAsync(CancellationTokencancellationToken){// Start the plugin}}
To get documentation up and running locally, do the following.
- Install
sphinx
:https://www.sphinx-doc.org - Install
sphinx_rtd_theme
:https://github.com/readthedocs/sphinx_rtd_theme - Run
make html source build
in the documentation folder - Open
documentation/build/html/index.html
in a browser to preview your changes
For Linux:
#In documentation folder:$sudo apt install python3 python3-sphinx python3-pip$python3 -m pip install sphinx-rtd-theme$make htmlsource build$sensible-browser build/html/index.html