public static RabbitMQAdapterReceiver Create(RabbitMQStreamProviderConfiguration configuration, string providerName, SerializationManager serializationManager, QueueId queueId, IRabbitMQDataAdapter dataAdapter, Logger logger) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (queueId == null) { throw new ArgumentNullException(nameof(queueId)); } if (dataAdapter == null) { throw new ArgumentNullException(nameof(dataAdapter)); } if (serializationManager == null) { throw new ArgumentNullException(nameof(serializationManager)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } var queue = RabbitMQResourceManager.CreateQueueDataManager(providerName, configuration, $"{providerName}_Consumer", logger); return(new RabbitMQAdapterReceiver(configuration, providerName, serializationManager, queueId, queue, dataAdapter, logger)); }
public async Task QueueMessageBatchAsync <T>(Guid streamGuid, string streamNamespace, IEnumerable <T> events, StreamSequenceToken token, Dictionary <string, object> requestContext) { var queueId = _streamQueueMapper.GetQueueForStream(streamGuid, streamNamespace); RabbitMQMessageQueueDataManager queue; if (!Queues.TryGetValue(queueId, out queue)) { var tmpQueue = RabbitMQResourceManager.CreateQueueDataManager(Name, _configuration, $"{Name}_Producer", _logger); await tmpQueue.InitQueueAsync(); queue = Queues.GetOrAdd(queueId, tmpQueue); } var rabbitMsg = _dataAdapter.ToRabbitMQMessage(streamGuid, streamNamespace, events, requestContext); await queue.AddQueueMessage(rabbitMsg); }
async Task IProvider.Close() { await RabbitMQResourceManager.Shutdown(Name); await base.Close(); }