try to refactor Kafka and add supports for RabbitMQ ...

This commit is contained in:
2026-08-18 17:53:35 +03:30
parent 3e0bb2c25f
commit b20c2f8db7
9 changed files with 861 additions and 5 deletions
+50
View File
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using RabbitMQ.Client;
using xCommons.Extensions;
using xEventService.Configuration;
using xEventService.Extensions;
using xExceptions.Constants;
namespace xEventService.Providers
{
/// <summary>
/// an Abstract Kafka Consumer Service ...
/// </summary>
public class XRabbitMQConsumerServiceBase : BackgroundService
{
protected readonly IModel channel;
protected readonly IConnection connection;
protected readonly XEventServiceConfiguration configuration;
protected readonly ILogger<XRabbitMQConsumerServiceBase> logger;
public XRabbitMQConsumerServiceBase(
XEventServiceConfiguration configuration,
ILogger<XRabbitMQConsumerServiceBase> logger
)
{
//
this.logger = logger;
this.configuration = configuration;
//
// Validate ...
if (!configuration.IsValid() ||
!configuration.RabbitMQ.IsValid() ||
configuration.Broker != Constants.XEventBroker.XRabbitMQ
)
{
XException.InvalidConfiguration.Throw();
}
}
public abstract Task HandleMessageAsync(
XEventMessage message,
CancellationToken cancellationToken = default
);
}
}