コード例 #1
0
        public static IQueueAdapterReceiver Create(SerializationManager serializationManager, QueueId queueId, string dataConnectionString, string deploymentId, IAzureQueueDataAdapter dataAdapter, TimeSpan?messageVisibilityTimeout = null)
        {
            if (queueId == null)
            {
                throw new ArgumentNullException(nameof(queueId));
            }
            if (string.IsNullOrEmpty(dataConnectionString))
            {
                throw new ArgumentNullException(nameof(dataConnectionString));
            }
            if (string.IsNullOrEmpty(deploymentId))
            {
                throw new ArgumentNullException(nameof(deploymentId));
            }
            if (dataAdapter == null)
            {
                throw new ArgumentNullException(nameof(dataAdapter));
            }
            if (serializationManager == null)
            {
                throw new ArgumentNullException(nameof(serializationManager));
            }

            var queue = new AzureQueueDataManager(queueId.ToString(), deploymentId, dataConnectionString, messageVisibilityTimeout);

            return(new AzureQueueAdapterReceiver(serializationManager, queueId, queue, dataAdapter));
        }
コード例 #2
0
        public Task QueueMessageBatchAsync <T>(Guid streamGuid,
                                               string streamNamespace,
                                               IEnumerable <T> events,
                                               StreamSequenceToken token,
                                               Dictionary <string, object> requestContext)
        {
            if (_publishSubscribe == null)
            {
                return(Task.CompletedTask);
            }

            QueueId queueId       = _streamQueueMapper.GetQueueForStream(streamGuid, streamNamespace);
            string  queueidString = queueId.ToString();

            foreach (T @event in events)
            {
                MessageData messageData = new MessageData(_serializationManager)
                {
                    Payload         = _serializationManager.SerializeToByteArray(@event),
                    StreamGuid      = streamGuid,
                    StreamNamespace = streamNamespace,
                    SequenceNumber  = DateTime.UtcNow.Ticks,
                    RequestContext  = requestContext
                };

                _publishSubscribe.Publish(queueidString, messageData);
            }

            return(Task.CompletedTask);
        }
コード例 #3
0
        public static IQueueAdapterReceiver Create(QueueId queueId, string rabbitMqConnectionString, string deploymentId = "")
        {
            if (queueId == null) throw new ArgumentNullException(nameof(queueId));
            if (String.IsNullOrEmpty(rabbitMqConnectionString)) throw new ArgumentNullException(nameof(rabbitMqConnectionString));

            var queue = new RabbitMessageQueueDataManager(queueId.ToString(), deploymentId, rabbitMqConnectionString);

            return new RabbitMessageQueueAdapterReceiver(queueId, queue);
        }
コード例 #4
0
        /// <summary>
        /// Creates a queue receiver for the specified queueId
        /// </summary>
        /// <param name="queueId"></param>
        /// <returns></returns>
        public IQueueAdapterReceiver CreateReceiver(QueueId queueId)
        {
            var dimensions      = new ReceiverMonitorDimensions(queueId.ToString());
            var receiverMonitor = this.ReceiverMonitorFactory(dimensions, this.telemetryProducer);
            var receiver        = receivers.GetOrAdd(queueId, new Receiver(receiverMonitor));

            SetGeneratorOnReceiver(receiver);
            return(receiver);
        }
コード例 #5
0
        /// <summary>
        /// Create a cache for a given queue id
        /// </summary>
        /// <param name="queueId"></param>
        public IQueueCache CreateQueueCache(QueueId queueId)
        {
            //move block pool creation from init method to here, to avoid unnecessary block pool creation when stream provider is initialized in client side.
            CreateBufferPoolIfNotCreatedYet();
            var logger  = this.loggerFactory.CreateLogger($"{typeof(MemoryPooledCache<TSerializer>).FullName}.{this.Name}.{queueId}");
            var monitor = this.CacheMonitorFactory(new CacheMonitorDimensions(queueId.ToString(), this.blockPoolMonitorDimensions.BlockPoolId), this.telemetryProducer);

            return(new MemoryPooledCache <TSerializer>(bufferPool, purgePredicate, logger, this.serializer, monitor, this.statisticOptions.StatisticMonitorWriteInterval));
        }
コード例 #6
0
 public static IQueueAdapterReceiver Create(QueueId queueId, string dataConnectionString, string deploymentId)
 {
     if (queueId == null) throw new ArgumentNullException("queueId");
     if (String.IsNullOrEmpty(dataConnectionString)) throw new ArgumentNullException("dataConnectionString");
     if (String.IsNullOrEmpty(deploymentId)) throw new ArgumentNullException("deploymentId");
     
     var queue = new AzureQueueDataManager(queueId.ToString(), deploymentId, dataConnectionString);
     return new AzureQueueAdapterReceiver(queueId, queue);
 }
コード例 #7
0
        /// <summary>
        /// Creates a queue receiver for the specified queueId
        /// </summary>
        /// <param name="queueId"></param>
        /// <returns></returns>
        public IQueueAdapterReceiver CreateReceiver(QueueId queueId)
        {
            var dimensions                 = new ReceiverMonitorDimensions(queueId.ToString());
            var receiverLogger             = this.loggerFactory.CreateLogger($"{typeof(MemoryAdapterReceiver<TSerializer>).FullName}.{this.Name}.{queueId}");
            var receiverMonitor            = this.ReceiverMonitorFactory(dimensions, this.telemetryProducer);
            IQueueAdapterReceiver receiver = new MemoryAdapterReceiver <TSerializer>(GetQueueGrain(queueId), receiverLogger, this.serializer, receiverMonitor);

            return(receiver);
        }
コード例 #8
0
        /// <summary>
        /// Create a cache for a given queue id
        /// </summary>
        /// <param name="queueId"></param>
        public IQueueCache CreateQueueCache(QueueId queueId)
        {
            //move block pool creation from init method to here, to avoid unnecessary block pool creation when stream provider is initialized in client side.
            CreateBufferPoolIfNotCreatedYet();
            var dimensions   = new CacheMonitorDimensions(this.sharedDimensions, queueId.ToString(), this.blockPoolMonitorDimensions.BlockPoolId);
            var cacheMonitor = this.CacheMonitorFactory(dimensions, logger.GetSubLogger(typeof(ICacheMonitor).Name));

            return(new GeneratorPooledCache(bufferPool, logger.GetSubLogger(typeof(GeneratorPooledCache).Name), serializationManager,
                                            cacheMonitor, this.adapterConfig.StatisticMonitorWriteInterval));
        }
コード例 #9
0
        public Task Initialize(TimeSpan timeout)
        {
            _subscription?.Dispose();
            _subscription = _publishSubscribe
                            .Observe <MessageData>(_queueId.ToString(), _queueId.ToString())
                            .Subscribe(tuple =>
            {
                switch (tuple.Data)
                {
                case MessageData messageData:
                    messageData.SerializationManager = _serializationManager;
                    break;
                }

                _batchContainers.Enqueue(tuple.Data);
            });

            return(Task.CompletedTask);
        }
コード例 #10
0
        /// <summary>
        /// Create a cache for a given queue id
        /// </summary>
        /// <param name="queueId"></param>
        public IQueueCache CreateQueueCache(QueueId queueId)
        {
            //move block pool creation from init method to here, to avoid unnecessary block pool creation when stream provider is initialized in client side.
            CreateBufferPoolIfNotCreatedYet();
            var dimensions   = new CacheMonitorDimensions(queueId.ToString(), this.blockPoolMonitorDimensions.BlockPoolId);
            var cacheMonitor = this.CacheMonitorFactory(dimensions, this.telemetryProducer);

            return(new GeneratorPooledCache(bufferPool, this.loggerFactory.CreateLogger($"{typeof(GeneratorPooledCache).FullName}.{this.Name}.{queueId}"), serializationManager,
                                            cacheMonitor, this.statisticOptions.StatisticMonitorWriteInterval));
        }
コード例 #11
0
        public IQueueAdapterReceiver CreateReceiver(QueueId queueId)
        {
            int maxRetry = 3;

            while (maxRetry-- > 0)
            {
                if (!_queueAdapterReceivers.TryGetValue(queueId.ToString(), out PublishSubscribeQueueAdapterReceiver adapterReceiver))
                {
                    adapterReceiver = new PublishSubscribeQueueAdapterReceiver(queueId, _publishSubscribe, _serializationManager);
                    if (!_queueAdapterReceivers.TryAdd(queueId.ToString(), adapterReceiver))
                    {
                        continue;
                    }
                }

                return(adapterReceiver);
            }

            throw new Exception("Internal exception, should not happen!");
        }
コード例 #12
0
        public static IQueueAdapterReceiver Create(ILoggerFactory loggerFactory, QueueId queueId, string projectId, string topicId,
                                                   string serviceId, IPubSubDataAdapter dataAdapter, TimeSpan?deadline = null, string customEndpoint = "")
        {
            if (queueId == null)
            {
                throw new ArgumentNullException(nameof(queueId));
            }
            if (dataAdapter == null)
            {
                throw new ArgumentNullException(nameof(dataAdapter));
            }

            var pubSub = new PubSubDataManager(loggerFactory, projectId, topicId, queueId.ToString(), serviceId, deadline, customEndpoint);

            return(new PubSubAdapterReceiver(loggerFactory, queueId, topicId, pubSub, dataAdapter));
        }
コード例 #13
0
        public static IQueueAdapterReceiver Create(QueueId queueId, string dataConnectionString, string deploymentId)
        {
            if (queueId == null)
            {
                throw new ArgumentNullException("queueId");
            }
            if (string.IsNullOrEmpty(dataConnectionString))
            {
                throw new ArgumentNullException("dataConnectionString");
            }
            if (string.IsNullOrEmpty(deploymentId))
            {
                throw new ArgumentNullException("deploymentId");
            }
            var queue = new RabbitMessageQueueDataManager(queueId.ToString(), deploymentId, dataConnectionString);

            return(new RabbitMessageQueueAdapterReceiver(queueId, queue));
        }
コード例 #14
0
        public async Task Initialize(TimeSpan timeout)
        {
            if (!_eventStoreRepository.IStarted)
            {
                await _eventStoreRepository.Connect(timeout);
            }

            var group = _queueId.ToString();

            await _eventStoreRepository.CreatePersistentSubscription(_providerName, group);

            _cleanUp = _eventStoreRepository.ObservePersistentSubscription(_providerName, group)
                       .Subscribe(ev =>
            {
                Debug.WriteLine($"{ev.StreamId} {ev.Version}");
                //todo: implement batch
                _receivedMessages.Enqueue(new EventStoreBatchContainer(Guid.Empty, ev.StreamId, ev, new EventStoreStreamSequenceToken(ev.Version)));
            });
        }
コード例 #15
0
        public static IQueueAdapterReceiver Create(Serializer <SQSBatchContainer> serializer, ILoggerFactory loggerFactory, QueueId queueId, string dataConnectionString, string serviceId)
        {
            if (queueId == null)
            {
                throw new ArgumentNullException("queueId");
            }
            if (string.IsNullOrEmpty(dataConnectionString))
            {
                throw new ArgumentNullException("dataConnectionString");
            }
            if (string.IsNullOrEmpty(serviceId))
            {
                throw new ArgumentNullException(nameof(serviceId));
            }

            var queue = new SQSStorage(loggerFactory, queueId.ToString(), dataConnectionString, serviceId);

            return(new SQSAdapterReceiver(serializer, loggerFactory, queueId, queue));
        }
コード例 #16
0
        public static IQueueAdapterReceiver Create(SerializationManager serializationManager, ILoggerFactory loggerFactory, QueueId queueId, string dataConnectionString, string deploymentId)
        {
            if (queueId == null)
            {
                throw new ArgumentNullException("queueId");
            }
            if (string.IsNullOrEmpty(dataConnectionString))
            {
                throw new ArgumentNullException("dataConnectionString");
            }
            if (string.IsNullOrEmpty(deploymentId))
            {
                throw new ArgumentNullException("deploymentId");
            }

            var queue = new SQSStorage(loggerFactory, queueId.ToString(), dataConnectionString, deploymentId);

            return(new SQSAdapterReceiver(serializationManager, loggerFactory, queueId, queue));
        }
コード例 #17
0
        public static IQueueAdapterReceiver Create(QueueId queueId, string dataConnectionString, string deploymentId, TimeSpan?messageVisibilityTimeout = null)
        {
            if (queueId == null)
            {
                throw new ArgumentNullException("queueId");
            }
            if (String.IsNullOrEmpty(dataConnectionString))
            {
                throw new ArgumentNullException("dataConnectionString");
            }
            if (String.IsNullOrEmpty(deploymentId))
            {
                throw new ArgumentNullException("deploymentId");
            }

            var queue = new AzureQueueDataManager(queueId.ToString(), deploymentId, dataConnectionString, messageVisibilityTimeout);

            return(new AzureQueueAdapterReceiver(queueId, queue));
        }
コード例 #18
0
        public static IQueueAdapterReceiver Create(SerializationManager serializationManager, Logger baseLogger, QueueId queueId, string projectId, string topicId,
                                                   string deploymentId, IPubSubDataAdapter dataAdapter, TimeSpan?deadline = null, string customEndpoint = "")
        {
            if (queueId == null)
            {
                throw new ArgumentNullException(nameof(queueId));
            }
            if (dataAdapter == null)
            {
                throw new ArgumentNullException(nameof(dataAdapter));
            }
            if (serializationManager == null)
            {
                throw new ArgumentNullException(nameof(serializationManager));
            }

            var pubSub = new PubSubDataManager(baseLogger, projectId, topicId, queueId.ToString(), deploymentId, deadline, customEndpoint);

            return(new PubSubAdapterReceiver(serializationManager, baseLogger, queueId, pubSub, dataAdapter));
        }
コード例 #19
0
        public static IQueueAdapterReceiver Create(QueueId queueId, string dataConnectionString, string deploymentId, int cacheSize)
        {
            if (queueId == null)
            {
                throw new ArgumentNullException("queueId");
            }
            if (String.IsNullOrEmpty(dataConnectionString))
            {
                throw new ArgumentNullException("dataConnectionString");
            }
            if (String.IsNullOrEmpty(deploymentId))
            {
                throw new ArgumentNullException("deploymentId");
            }
            if (cacheSize <= 0)
            {
                throw new ArgumentOutOfRangeException("cacheSize", "CacheSize must be positive number.");
            }

            var queue = new AzureQueueDataManager(queueId.ToString(), deploymentId, dataConnectionString);

            return(new AzureQueueAdapterReceiver(queueId, queue, cacheSize));
        }
コード例 #20
0
        /// <summary>
        /// Creates a quere receiver for the specificed queueId
        /// </summary>
        /// <param name="queueId"></param>
        /// <returns></returns>
        public IQueueAdapterReceiver CreateReceiver(QueueId queueId)
        {
            var      dimensions      = new ReceiverMonitorDimensions(this.sharedDimensions, queueId.ToString());
            var      receiverMonitor = this.ReceiverMonitorFactory(dimensions, logger.GetSubLogger(typeof(IQueueAdapterReceiverMonitor).Name));
            Receiver receiver        = receivers.GetOrAdd(queueId, qid => new Receiver(receiverMonitor));

            SetGeneratorOnReciever(receiver);
            return(receiver);
        }
コード例 #21
0
 public RabbitMqConnector(RabbitMqStreamProviderOptions options, QueueId queueId, Logger logger)
 {
     _options  = options;
     QueueName = queueId.ToString();
     Logger    = logger;
 }
コード例 #22
0
        /// <summary>
        /// Creates a quere receiver for the specificed queueId
        /// </summary>
        /// <param name="queueId"></param>
        /// <returns></returns>
        public IQueueAdapterReceiver CreateReceiver(QueueId queueId)
        {
            var dimensions                 = new ReceiverMonitorDimensions(this.sharedDimensions, queueId.ToString());
            var receiverLogger             = logger.GetSubLogger(typeof(MemoryAdapterReceiver <TSerializer>).Name);
            var receiverMonitor            = this.ReceiverMonitorFactory(dimensions, receiverLogger.GetSubLogger(typeof(IQueueAdapterReceiverMonitor).Name));
            IQueueAdapterReceiver receiver = new MemoryAdapterReceiver <TSerializer>(GetQueueGrain(queueId), receiverLogger, this.serializer, receiverMonitor);

            return(receiver);
        }
 public string QueueIdToQueueName(QueueId queueId)
 {
     return(queueId.ToString());
 }
コード例 #24
0
        /// <summary>
        /// Create a cache for a given queue id
        /// </summary>
        /// <param name="queueId"></param>
        public IQueueCache CreateQueueCache(QueueId queueId)
        {
            //move block pool creation from init method to here, to avoid unnecessary block pool creation when stream provider is initialized in client side.
            CreateBufferPoolIfNotCreatedYet();
            var logger  = this.logger.GetSubLogger(typeof(MemoryPooledCache <TSerializer>).Name);
            var monitor = this.CacheMonitorFactory(new CacheMonitorDimensions(this.sharedDimensions, queueId.ToString(), this.blockPoolMonitorDimensions.BlockPoolId), logger.GetSubLogger(typeof(ICacheMonitor).Name));

            return(new MemoryPooledCache <TSerializer>(bufferPool, purgePredicate, logger, this.serializer, monitor, this.adapterConfig.StatisticMonitorWriteInterval));
        }