示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        async Task IProvider.Close()
        {
            await RabbitMQResourceManager.Shutdown(Name);

            await base.Close();
        }