QortexMQ.Client
1.3.0
dotnet add package QortexMQ.Client --version 1.3.0
NuGet\Install-Package QortexMQ.Client -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="QortexMQ.Client" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="QortexMQ.Client" Version="1.3.0" />
<PackageReference Include="QortexMQ.Client" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add QortexMQ.Client --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: QortexMQ.Client, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package QortexMQ.Client@1.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=QortexMQ.Client&version=1.3.0
#tool nuget:?package=QortexMQ.Client&version=1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
QortexMQ Client
Improved QortexMQ client library with better architecture, error handling, and performance.
Features
- Improved Architecture: Clean separation of concerns with dedicated components
- Better Error Handling: Comprehensive exception handling and recovery
- Automatic Reconnection: Configurable reconnection with exponential backoff
- Thread Safety: Thread-safe operations with proper synchronization
- Performance Optimized: Efficient message processing with configurable concurrency
- Flexible Configuration: Extensive configuration options for different use cases
- Modern C#: Built with .NET 8 and modern C# features
- Comprehensive Logging: Detailed logging with structured logging support
Quick Start
Basic Usage
using QortexMQ;
// Create client
using var client = new QortexMqClient("localhost", 9090);
// Connect to server
await client.ConnectAsync();
// Subscribe to topic
await client.SubscribeAsync<string>("test-topic", async (message) =>
{
Console.WriteLine($"Received: {message}");
await Task.Delay(100);
});
// Publish message
await client.PublishAsync<string>("test-topic", "Hello, World!");
Builder Pattern
using var client = QortexMqClientFactory.CreateBuilder()
.WithServerAddress("localhost")
.WithServerPort(9090)
.WithConnectionTimeout(15000)
.WithReconnectionDelay(3000)
.WithMaxReconnectionAttempts(10)
.WithAutoReconnection(true)
.WithMaxConcurrentHandlers(5)
.WithMessageSendTimeout(8000)
.WithKeepAlive(true, 120, 20)
.WithNoDelay(true)
.WithBufferSizes(32768, 32768)
.Build();
Configuration Options
| Option | Default | Description |
|---|---|---|
ServerAddress |
Required | Server IP address or hostname |
ServerPort |
Required | Server port number |
ConnectionTimeoutMs |
30000 | Connection timeout in milliseconds |
ReconnectionDelayMs |
1000 | Delay between reconnection attempts |
MaxReconnectionAttempts |
0 | Maximum reconnection attempts (0 = unlimited) |
EnableAutoReconnection |
true | Enable automatic reconnection |
MaxConcurrentHandlersPerSubscription |
1 | Maximum concurrent message handlers |
MessageSendTimeoutMs |
5000 | Message send timeout in milliseconds |
EnableKeepAlive |
true | Enable TCP keep-alive |
KeepAliveTimeSeconds |
60 | TCP keep-alive time |
KeepAliveIntervalSeconds |
10 | TCP keep-alive interval |
EnableNoDelay |
true | Enable TCP no-delay |
ReceiveBufferSize |
8192 | TCP receive buffer size |
SendBufferSize |
8192 | TCP send buffer size |
API Reference
Core Methods
ConnectAsync()- Connect to serverDisconnectAsync()- Disconnect from serverPublishAsync<T>()- Publish message to topicSubscribeAsync<T>()- Subscribe to topicUnsubscribeAsync()- Unsubscribe from topic
Properties
Connected- Connection statusSubscriptionCount- Number of active subscriptionsConnectionStateChanged- Connection state change event
Events
ConnectionStateChanged- Fired when connection state changes
Error Handling
The client provides comprehensive error handling:
try
{
using var client = new QortexMqClient("localhost", 9090);
await client.ConnectAsync();
// Subscribe with error handling
await client.SubscribeAsync<string>("topic", async (message) =>
{
try
{
// Process message
await ProcessMessage(message);
}
catch (Exception ex)
{
// Log error and re-throw to send failed acknowledgment
_logger.LogError(ex, "Error processing message");
throw;
}
});
}
catch (InvalidOperationException ex)
{
// Handle connection errors
Console.WriteLine($"Connection failed: {ex.Message}");
}
catch (Exception ex)
{
// Handle other errors
Console.WriteLine($"Unexpected error: {ex.Message}");
}
Performance Considerations
- Use appropriate
MaxConcurrentHandlersPerSubscriptionbased on your workload - Enable TCP optimizations (
NoDelay,KeepAlive) for better performance - Configure buffer sizes based on message sizes
- Use structured logging for better performance monitoring
Requirements
- .NET 8.0 or later
- MessagePack library
- Microsoft.Extensions.Logging (optional)
See LICENSE.txt for license information.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- MessagePack (>= 3.1.3)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Console (>= 8.0.0)
- QortexMQ.Common (>= 1.3.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Some fixes