Gtlabs.ServiceBus
1.4.1
dotnet add package Gtlabs.ServiceBus --version 1.4.1
NuGet\Install-Package Gtlabs.ServiceBus -Version 1.4.1
<PackageReference Include="Gtlabs.ServiceBus" Version="1.4.1" />
<PackageVersion Include="Gtlabs.ServiceBus" Version="1.4.1" />
<PackageReference Include="Gtlabs.ServiceBus" />
paket add Gtlabs.ServiceBus --version 1.4.1
#r "nuget: Gtlabs.ServiceBus, 1.4.1"
#:package Gtlabs.ServiceBus@1.4.1
#addin nuget:?package=Gtlabs.ServiceBus&version=1.4.1
#tool nuget:?package=Gtlabs.ServiceBus&version=1.4.1
Gtlabs.ServiceBus
Abstractions and integrations for messaging based on Rebus/RabbitMQ. Enables automatic handler registration, dynamic routing of commands and messages, and custom serialization for interoperability between services.
Usage
Add the package to your project and register ServiceBus in the DI pipeline:
services.RegisterServiceBus(configuration);
How to implement a new Command
- Create a class that implements
ICommand. - Add the
[CommandAttribute]specifying the queue name and the remote corresponding Message type.
using Gtlabs.ServiceBus.ServiceBus.Contracts;
[CommandAttribute("my-registered-queue", "Complete.Remote.Message.Namespace")]
public class MyNewCommand : ICommand
{
public string Property { get; set; }
}
How to implement a new Message
- Create a class that implements
IMessage. - Add the
[MessageAttribute]specifying the full type.
using Gtlabs.ServiceBus.ServiceBus.Contracts;
[MessageAttribute("Full.Message.Namespace")]
public class MyMessage : IMessage
{
public int Value { get; set; }
}
Handlers
To process messages, implement a handler using IHandleMessages<T>:
using Rebus.Handlers;
public class MyNewCommandHandler : IHandleMessages<MyMessage>
{
public async Task Handle(MyMessage message)
{
// Processing logic
}
}
Handlers are automatically registered by the package.
Distributed tracing
The package propagates W3C trace context through Rebus headers:
traceparenttracestate
Outgoing messages create producer activities and incoming message handlers create consumer activities. When Gtlabs.Logging tracing is enabled, Rebus message handling appears in the same distributed trace tree as HTTP requests and outgoing HTTP calls.
Required environment variables
ServiceBus:ConnectionString: RabbitMQ connection string (e.g.,amqp://user:pass@host:port/vhost, usually registered in Consul K/V)AppId: Unique application identifier (usually registered by Gtlabs.AppRegistration)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Gtlabs.Consts (>= 1.4.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.9)
- Rebus (>= 8.8.0)
- Rebus.Events (>= 6.0.0)
- Rebus.RabbitMq (>= 10.0.2)
- Rebus.ServiceProvider (>= 10.5.0)
- Scrutor (>= 6.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.