GobanSource.Bus.Redis
0.1.2.16
Prefix Reserved
See the version list below for details.
dotnet add package GobanSource.Bus.Redis --version 0.1.2.16
NuGet\Install-Package GobanSource.Bus.Redis -Version 0.1.2.16
<PackageReference Include="GobanSource.Bus.Redis" Version="0.1.2.16" />
<PackageVersion Include="GobanSource.Bus.Redis" Version="0.1.2.16" />
<PackageReference Include="GobanSource.Bus.Redis" />
paket add GobanSource.Bus.Redis --version 0.1.2.16
#r "nuget: GobanSource.Bus.Redis, 0.1.2.16"
#:package GobanSource.Bus.Redis@0.1.2.16
#addin nuget:?package=GobanSource.Bus.Redis&version=0.1.2.16
#tool nuget:?package=GobanSource.Bus.Redis&version=0.1.2.16
GobanSource.Bus.Redis
A lightweight, Redis-based message bus library for .NET applications. Enables communication between distributed application instances using Redis Pub/Sub.
Features
- True Fan-Out Messaging: Each message is delivered to all active subscribers across different application instances
- Instance Filtering: Messages from the same instance are automatically skipped
- Type-Safe Message Handling: Generic interfaces for strongly-typed message processing
- No Message Persistence: Only active subscribers receive messages (suitable for cache synchronization)
- Easy Integration: Works with .NET's dependency injection and hosted services
Installation
dotnet add package GobanSource.Bus.Redis
Requirements
- .NET Standard 2.0+
- Redis server
Quick Start
1. Define your message type
public class SimpleMessage : BaseMessage
{
public string Data { get; set; } = null!;
}
2. Create a message handler
public class SimpleMessageHandler : IMessageHandler<SimpleMessage>
{
private readonly ILogger<SimpleMessageHandler> _logger;
public SimpleMessageHandler(ILogger<SimpleMessageHandler> logger)
{
_logger = logger;
}
public async Task HandleAsync(SimpleMessage message)
{
_logger.LogInformation("Received message: {Data}", message.Data);
// Process the message here
await Task.CompletedTask;
}
}
3. Register services in your application
// Add Redis connection
services.AddSingleton<IConnectionMultiplexer>(sp =>
ConnectionMultiplexer.Connect("localhost:6379"));
// Register the message bus for SimpleMessage
services.AddTransient<IRedisSyncBus<SimpleMessage>>(sp => new RedisSyncBus<SimpleMessage>(
sp.GetRequiredService<IConnectionMultiplexer>(),
"myapp", // Your application ID
"messages", // Channel prefix
sp.GetRequiredService<ILogger<RedisSyncBus<SimpleMessage>>>()));
// Register the message handler
services.AddTransient<IMessageHandler<SimpleMessage>, SimpleMessageHandler>();
// Register the hosted service that connects the bus to the handler
services.AddHostedService<MessageSyncHostedService<SimpleMessage>>();
4. Publish messages
public class MessagePublisher
{
private readonly IRedisSyncBus<SimpleMessage> _bus;
public MessagePublisher(IRedisSyncBus<SimpleMessage> bus)
{
_bus = bus;
}
public async Task SendMessageAsync(string data)
{
await _bus.PublishAsync(new SimpleMessage
{
Data = data
});
}
}
How It Works
GobanSource.Bus.Redis uses Redis Pub/Sub channels to publish and subscribe to messages between different application instances. When a message is published:
- The message is serialized and published to a Redis channel with a pattern:
{prefix}:{appId}:{messageType}
- Redis broadcasts the message to all subscribers of that channel
- Each subscriber receives and processes the message if it's from a different instance
- Messages from the same instance (identified by InstanceId) are automatically skipped
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
- Built and maintained by Goban Source
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- StackExchange.Redis (>= 2.8.24)
- System.Text.Json (>= 8.0.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on GobanSource.Bus.Redis:
Package | Downloads |
---|---|
GobanSource.ReplicatedLruCache
A lightweight, replicated LRU cache library for .NET applications. replicated by redis pub/sub. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.44 | 139 | 7/11/2025 |
1.0.42 | 261 | 6/16/2025 |
1.0.40 | 128 | 6/15/2025 |
1.0.38 | 198 | 6/14/2025 |
0.1.2.29 | 276 | 6/13/2025 |
0.1.2.26 | 143 | 4/25/2025 |
0.1.2.23 | 192 | 4/15/2025 |
0.1.2.21 | 196 | 4/15/2025 |
0.1.2.19-pre | 207 | 4/15/2025 |
0.1.2.17 | 194 | 4/15/2025 |
0.1.2.16 | 202 | 4/14/2025 |
0.1.2 | 200 | 4/14/2025 |
0.1.1 | 218 | 4/14/2025 |
0.1.0 | 147 | 4/12/2025 |