public void Start()
		{
			_scope = _eventAggregator.NewSubscriptionScope();
			_scope.Subscribe<ReceiveCompleted>(Handle);
			_scope.Subscribe<ConsumeCompleted>(Handle);

			_enabled = true;

			if (_log.IsDebugEnabled)
				_log.DebugFormat("Starting Consumer Pool for {0}", _bus.Endpoint.Uri);

			QueueReceiver();
		}
        public void Start()
        {
            _scope = _eventAggregator.NewSubscriptionScope();
            _scope.Subscribe <ReceiveCompleted>(Handle);
            _scope.Subscribe <ConsumeCompleted>(Handle);

            _enabled = true;

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting Consumer Pool for {0}", _bus.Endpoint.Uri);
            }

            QueueReceiver();
        }
Beispiel #3
0
        public void Setup()
        {
            _addCalled = new Future<bool>();
            _removeCalled = new Future<bool>();

            _input = PipeSegment.Input(PipeSegment.End());

            _subscriberScope = _input.NewSubscriptionScope();
            _subscriberScope.Subscribe<SubscriberAdded>(x => _addCalled.Complete(true));
            _subscriberScope.Subscribe<SubscriberRemoved>(x => _removeCalled.Complete(true));

            using (var scope = _input.NewSubscriptionScope())
            {
                scope.Subscribe<ClaimModified>(x => { });
            }
        }
Beispiel #4
0
        public void Setup()
        {
            _addCalled    = new Future <bool>();
            _removeCalled = new Future <bool>();

            _input = PipeSegment.Input(PipeSegment.End());

            _subscriberScope = _input.NewSubscriptionScope();
            _subscriberScope.Subscribe <SubscriberAdded>(x =>
            {
                if (x.MessageType == typeof(ClaimModified))
                {
                    _addCalled.Complete(true);
                }
            });
            _subscriberScope.Subscribe <SubscriberRemoved>(x =>
            {
                if (x.MessageType == typeof(ClaimModified))
                {
                    _removeCalled.Complete(true);
                }
            });

            using (ISubscriptionScope scope = _input.NewSubscriptionScope())
            {
                scope.Subscribe <ClaimModified>(x => { });
            }
        }
Beispiel #5
0
        public void Second_example()
        {
            _eventAggregator = PipeSegment.Input(PipeSegment.End());

            _scope = _eventAggregator.NewSubscriptionScope();
            _scope.Subscribe <CustomerChanged>(message => Trace.WriteLine("Customer changed: " + message.CustomerName));

            new TracePipeVisitor().Trace(_eventAggregator);
        }
Beispiel #6
0
        public void Second_example()
        {
            _eventAggregator = PipeSegment.Input(PipeSegment.End());

            _scope = _eventAggregator.NewSubscriptionScope();
            _scope.Subscribe<CustomerChanged>(message => Trace.WriteLine("Customer changed: " + message.CustomerName));

            new TracePipeVisitor().Trace(_eventAggregator);
        }
        public void Setup()
        {
            _pipe = PipeSegment.Input(PipeSegment.End<object>());
            _subscriptionScope = _pipe.NewSubscriptionScope();

            _called = new ManualResetEvent(false);
            _subscriptionScope.Subscribe<ClaimModified>(x => _called.Set());

            EstablishContext();
        }
Beispiel #8
0
        public void Setup()
        {
            _pipe = PipeSegment.Input(PipeSegment.End <object>());
            _subscriptionScope = _pipe.NewSubscriptionScope();

            _called = new ManualResetEvent(false);
            _subscriptionScope.Subscribe <ClaimModified>(x => _called.Set());

            EstablishContext();
        }
        private void InitializePerformanceCounters()
        {
            try
            {
                var instanceName = string.Format("{0}_{1}_{2}", Endpoint.Address.Path, Endpoint.Uri.Scheme, Endpoint.Uri.Host);

                _counters = new ServiceBusInstancePerformanceCounters(instanceName);

                _eventAggregatorScope.Subscribe <MessageReceived>(message =>
                {
                    _counters.ReceiveCount.Increment();
                    _counters.ReceiveRate.Increment();
                    _counters.ReceiveDuration.IncrementBy((long)message.ReceiveDuration.TotalMilliseconds);
                    _counters.ReceiveDurationBase.Increment();
                    _counters.ConsumerDuration.IncrementBy((long)message.ConsumeDuration.TotalMilliseconds);
                    _counters.ConsumerDurationBase.Increment();
                });

                _eventAggregatorScope.Subscribe <MessagePublished>(message =>
                {
                    _counters.PublishCount.Increment();
                    _counters.PublishRate.Increment();
                    _counters.PublishDuration.IncrementBy((long)message.Duration.TotalMilliseconds);
                    _counters.PublishDurationBase.Increment();

                    _counters.SentCount.IncrementBy(message.ConsumerCount);
                    _counters.SendRate.IncrementBy(message.ConsumerCount);
                });

                _eventAggregatorScope.Subscribe <ThreadPoolEvent>(message =>
                {
                    _counters.ReceiveThreadCount.Set(message.ReceiverCount);
                    _counters.ConsumerThreadCount.Set(message.ConsumerCount);
                });
            }
            catch (Exception ex)
            {
                _log.Warn("The performance counters could not be created", ex);
            }
        }
Beispiel #10
0
        public void Setup()
        {
            _addCalled = new Future<bool>();
            _removeCalled = new Future<bool>();

            _input = PipeSegment.Input(PipeSegment.End());

            _subscriberScope = _input.NewSubscriptionScope();
            _subscriberScope.Subscribe<SubscriberAdded>(x =>
                {
                    if(x.MessageType == typeof(ClaimModified))
                        _addCalled.Complete(true);
                });
            _subscriberScope.Subscribe<SubscriberRemoved>(x =>
                {
                    if (x.MessageType == typeof(ClaimModified))
                        _removeCalled.Complete(true);
                });

            using (ISubscriptionScope scope = _input.NewSubscriptionScope())
            {
                scope.Subscribe<ClaimModified>(x => { });
            }
        }
        public void Stop()
        {
            _enabled = false;

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Stopping Consumer Pool for {0}", _bus.Endpoint.Uri);
            }

            if (_consumerCount == 0)
            {
                return;
            }

            var completed = new AutoResetEvent(true);

            _scope.Subscribe <ConsumeCompleted>(x => completed.Set());

            while (completed.WaitOne(60.Seconds(), true))
            {
                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Consumer Pool stopped for {0}", _bus.Endpoint.Uri);
                }

                if (_consumerCount == 0)
                {
                    return;
                }
            }

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Timeout stopping Consumer Pool for {0}", _bus.Endpoint.Uri);
            }
        }
Beispiel #12
0
 public void Subscribe <T>(Action <T> actOnEvent) where T : class
 {
     _scope.Subscribe(new DelegatingConsumer <T>(actOnEvent));
 }
Beispiel #13
0
 public IMessenger Subscribe <T>(T consumer) where T : class
 {
     mySubscriptionScope.Subscribe(consumer);
     return(this);
 }
Beispiel #14
0
        public void Multiple_consumers_should_create_a_recipient_list()
        {
            _scope.Subscribe <ClaimModified>(x => { });

            _pipe.Send(new ClaimCreated());
        }
Beispiel #15
0
 public void Setup()
 {
     _pipe  = PipeSegment.Input(PipeSegment.End <ClaimModified>());
     _scope = _pipe.NewSubscriptionScope();
     _scope.Subscribe <ClaimModified>(x => { });
 }
Beispiel #16
0
 public void Setup()
 {
     _pipe = PipeSegment.Input(PipeSegment.End<ClaimModified>());
     _scope = _pipe.NewSubscriptionScope();
     _scope.Subscribe<ClaimModified>(x => { });
 }