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 { /// /// an Abstract Kafka Consumer Service ... /// public class XRabbitMQConsumerServiceBase : BackgroundService { protected readonly IModel channel; protected readonly IConnection connection; protected readonly XEventServiceConfiguration configuration; protected readonly ILogger logger; public XRabbitMQConsumerServiceBase( XEventServiceConfiguration configuration, ILogger 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 ); } }