示例#1
0
文件: Bus.cs 项目: lulzzz/Kontur
        public ISubscriptionTag Subscribe <T>(ISubscriber subscriber, int queueCapacity = 1)
        {
            DataflowBlockOptions queueOptions = new DataflowBlockOptions
            {
                BoundedCapacity = queueCapacity
            };

            MessageBuffer    workerQueue   = new MessageBuffer(queueOptions);
            ISubscriptionTag subscriberTag = subscriber.SubscribeTo(workerQueue);

            ISubscriptionTag dispatcherTag = this.LinkDispatcherTo <T>(workerQueue);

            subscriberTag = new CompositeSubscriptionTag(Guid.NewGuid().ToString(), subscriberTag, dispatcherTag);
            subscribers.AddOrUpdate(subscriberTag.Id, subscriberTag, (o, n) => n);

            return(subscriberTag);
        }
示例#2
0
文件: Bus.cs 项目: alexzaitzev/Kontur
        public ISubscriptionTag Subscribe <T>(ISubscriber subscriber, int queueCapacity = 1)
        {
            this.logService.Info("Creating subscription to {0} with the queue capacity equals: {1}.", typeof(T), queueCapacity);
            DataflowBlockOptions queueOptions = new DataflowBlockOptions
            {
                BoundedCapacity = queueCapacity
            };

            MessageBuffer    workerQueue   = new MessageBuffer(queueOptions);
            ISubscriptionTag subscriberTag = subscriber.SubscribeTo(workerQueue);

            ISubscriptionTag dispatcherTag = this.LinkDispatcherTo <T>(workerQueue);

            subscriberTag = new CompositeSubscriptionTag(Guid.NewGuid().ToString(), subscriberTag, dispatcherTag);
            subscribers.AddOrUpdate(subscriberTag.Id, subscriberTag, (o, n) => n);

            return(subscriberTag);
        }