示例#1
0
 public RabbitMqConnector(RabbitMqOptions options, QueueId queueId, ILogger logger)
 {
     _options  = options;
     Logger    = logger;
     QueueName = options.UseQueuePartitioning
         ? $"{options.QueueNamePrefix}-{queueId.GetNumericId()}"
         : options.QueueNamePrefix;
 }
        public IQueueAdapterReceiver CreateReceiver(QueueId queueId)
        {
            var partitionId = (int)queueId.GetNumericId();
            var clientName  = Environment.MachineName + AppDomain.CurrentDomain.FriendlyName;

            // Creating a receiver
            var manualConsumer   = new ManualConsumer(partitionId, _options.TopicName, _gateway, clientName, _options.MaxBytesInMessageSet);
            var receiverToReturn = new KafkaQueueAdapterReceiver(queueId, manualConsumer, _options, _batchFactory, _logger);

            return(receiverToReturn);
        }
        public KafkaQueueAdapterReceiver(QueueId queueId, IManualConsumer consumer, KafkaStreamProviderOptions options,
            IKafkaBatchFactory factory, Logger logger)
        {
            // input checks
            if (queueId == null) throw new ArgumentNullException(nameof(queueId));
            if (consumer == null) throw new ArgumentNullException(nameof(consumer));
            if (factory == null) throw new ArgumentNullException(nameof(factory));
            if (options == null) throw new ArgumentNullException(nameof(options));
            if (logger == null) throw new ArgumentNullException(nameof(logger));

            _counterCurrentOffset = Metric.Context("KafkaStreamProvider").Counter($"CurrentOffset queueId:({queueId.GetNumericId()})", unit:  Unit.Custom("Log"));
       
            _options = options;
            Id = queueId;
            _consumer = consumer;
            _factory = factory;
            _logger = logger;
        }
        public TimedQueueCache(QueueId queueId, TimeSpan cacheTimespan, int cacheSize, int numOfBuckets, Logger logger)
        {
            _counterMessagesInCache = Metric.Context("KafkaStreamProvider").Counter($"Messages In Cache queueId:({queueId.GetNumericId()})", Unit.Items);
            _meterCacheEvacuationsPerSecond = Metric.Context("KafkaStreamProvider").Meter($"Cache Evacuations Per Second queueId:({queueId.GetNumericId()})", Unit.Items);
            _counterNumberOfCursorsCausingPressure = Metric.Context("KafkaStreamProvider").Counter($"Cursors causing pressure queueId:({queueId.GetNumericId()})", Unit.Items);

            Id = queueId;
            _cachedMessages = new LinkedList<TimedQueueCacheItem>();

            _logger = logger;
            _cacheCursorHistogram = new List<TimedQueueCacheBucket>();

            _maxCacheSize = cacheSize;
            _cacheHistogramMaxBucketSize = Math.Max(_maxCacheSize / numOfBuckets, 1);
            _maxNumberToAdd = _cacheHistogramMaxBucketSize;
            _cacheTimeSpan = cacheTimespan;
            _bucketTimeSpan = TimeSpan.FromMilliseconds(cacheTimespan.TotalMilliseconds / numOfBuckets);
        }
示例#5
0
        public KafkaQueueAdapterReceiver(QueueId queueId, IManualConsumer consumer, KafkaStreamProviderOptions options,
                                         IKafkaBatchFactory factory, ILogger logger)
        {
            // input checks
            if (queueId == null)
            {
                throw new ArgumentNullException(nameof(queueId));
            }
            if (consumer == null)
            {
                throw new ArgumentNullException(nameof(consumer));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _counterCurrentOffset = Metrics.Metric.Context("KafkaStreamProvider").Counter($"CurrentOffset queueId:({queueId.GetNumericId()})", unit:  Unit.Custom("Log"));

            _options  = options;
            Id        = queueId;
            _consumer = consumer;
            _factory  = factory;
            _logger   = logger;
        }
示例#6
0
        public TimedQueueCache(QueueId queueId, TimeSpan cacheTimespan, int cacheSize, int numOfBuckets, ILogger logger)
        {
            _counterMessagesInCache                = Metrics.Metric.Context("KafkaStreamProvider").Counter($"Messages In Cache queueId:({queueId.GetNumericId()})", Unit.Items);
            _meterCacheEvacuationsPerSecond        = Metrics.Metric.Context("KafkaStreamProvider").Meter($"Cache Evacuations Per Second queueId:({queueId.GetNumericId()})", Unit.Items);
            _counterNumberOfCursorsCausingPressure = Metrics.Metric.Context("KafkaStreamProvider").Counter($"Cursors causing pressure queueId:({queueId.GetNumericId()})", Unit.Items);

            Id = queueId;
            _cachedMessages = new LinkedList <TimedQueueCacheItem>();

            _logger = logger;
            _cacheCursorHistogram = new List <TimedQueueCacheBucket>();

            _maxCacheSize = cacheSize;
            _cacheHistogramMaxBucketSize = Math.Max(_maxCacheSize / numOfBuckets, 1);
            _maxNumberToAdd = _cacheHistogramMaxBucketSize;
            _cacheTimeSpan  = cacheTimespan;
            _bucketTimeSpan = TimeSpan.FromMilliseconds(cacheTimespan.TotalMilliseconds / numOfBuckets);
        }
示例#7
0
 public virtual string GetNameForQueue(QueueId queueId)
 {
     return(options.UseQueuePartitioning
         ? $"{queueId.GetStringNamePrefix()}-{queueId.GetNumericId()}"
         : queueId.GetStringNamePrefix());
 }
示例#8
0
 public override string GetNameForQueue(QueueId queueId)
 {
     return(CustomQueueNames[(int)queueId.GetNumericId()]);
 }