Exemplo n.º 1
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 => { });
            }
        }
Exemplo n.º 2
0
        public void Setup()
        {
            Input = PipeSegment.Input(PipeSegment.End());
            Scope = Input.NewSubscriptionScope();

            EstablishContext();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an instance of the ServiceBus, which implements IServiceBus. This is normally
        /// not called and should be created using the ServiceBusConfigurator to ensure proper defaults
        /// and operation.
        /// </summary>
        public ServiceBus(IEndpoint endpointToListenOn,
                          IObjectBuilder objectBuilder,
                          IEndpointFactory endpointFactory)
        {
            ReceiveTimeout = TimeSpan.FromSeconds(3);
            endpointToListenOn.MustNotBeNull("endpointToListenOn", "This parameter cannot be null");
            objectBuilder.MustNotBeNull("objectBuilder", "This parameter cannot be null");
            endpointFactory.MustNotBeNull("endpointFactory", "This parameter cannot be null");

            Endpoint        = endpointToListenOn;
            ObjectBuilder   = objectBuilder;
            EndpointFactory = endpointFactory;

            _eventAggregator      = PipeSegment.New();
            _eventAggregatorScope = _eventAggregator.NewSubscriptionScope();

            _serviceContainer = new ServiceContainer(this);

            OutboundPipeline = MessagePipelineConfigurator.CreateDefault(ObjectBuilder, this);

            InboundPipeline = MessagePipelineConfigurator.CreateDefault(ObjectBuilder, this);
            InboundPipeline.Configure(x => { _unsubscribeEventDispatchers += x.Register(new InboundOutboundSubscriptionBinder(OutboundPipeline, Endpoint)); });

            PoisonEndpoint = new PoisonEndpointDecorator(new NullEndpoint());

            ControlBus = this;

            InitializePerformanceCounters();
        }
Exemplo n.º 4
0
        public void Setup()
        {
            Input = PipeSegment.Input(PipeSegment.End());
            Scope = Input.NewSubscriptionScope();

            EstablishContext();
        }
Exemplo n.º 5
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            if (disposing)
            {
                if (_consumerPool != null)
                {
                    _consumerPool.Stop();
                    _consumerPool.Dispose();
                    _consumerPool = null;
                }

                if (_serviceContainer != null)
                {
                    _serviceContainer.Stop();
                    _serviceContainer.Dispose();
                    _serviceContainer = null;
                }

                if (ControlBus != this)
                {
                    ControlBus.Dispose();
                }

                _unsubscribeEventDispatchers();

                InboundPipeline.Dispose();
                InboundPipeline = null;

                OutboundPipeline.Dispose();
                OutboundPipeline = null;

                if (_eventAggregatorScope != null)
                {
                    _eventAggregatorScope.Dispose();
                    _eventAggregatorScope = null;
                }

                _eventAggregator = null;

                Endpoint = null;

                if (_counters != null)
                {
                    _counters.Dispose();
                    _counters = null;
                }

                if (PoisonEndpoint != null)
                {
                    PoisonEndpoint = null;
                }
            }
            _disposed = true;
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 9
0
        public void Teardown()
        {
            if(_scope != null)
            {
                _scope.Dispose();
                _scope = null;
            }

            _eventAggregator = null;
        }
Exemplo n.º 10
0
        public void Setup()
        {
            _pipe = PipeSegment.Input(PipeSegment.End <object>());
            _subscriptionScope = _pipe.NewSubscriptionScope();

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

            EstablishContext();
        }
Exemplo n.º 11
0
        public void Teardown()
        {
            if (_scope != null)
            {
                _scope.Dispose();
                _scope = null;
            }

            _eventAggregator = null;
        }
Exemplo n.º 12
0
		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();
		}
Exemplo n.º 13
0
        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();
        }
Exemplo n.º 14
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 => { });
            }
        }
Exemplo n.º 15
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            if (disposing)
            {
                if (_scope != null)
                {
                    _scope.Dispose();
                    _scope = null;
                }
            }

            _disposed = true;
        }
Exemplo n.º 16
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 => { });
            }
        }
Exemplo n.º 17
0
 public void Teardown()
 {
     _subscriptionScope.Dispose();
     _subscriptionScope = null;
 }
Exemplo n.º 18
0
 public EventsProvider()
 {
     _eventsPipe = PipeSegment.Input(PipeSegment.End());;
     _scope      = _eventsPipe.NewSubscriptionScope();
 }
Exemplo n.º 19
0
 public void Setup()
 {
     _pipe = PipeSegment.Input(PipeSegment.End<ClaimModified>());
     _scope = _pipe.NewSubscriptionScope();
     _scope.Subscribe<ClaimModified>(x => { });
 }
Exemplo n.º 20
0
 static MagnumMessenger()
 {
     myMessageBus        = PipeSegment.Input(PipeSegment.End());
     mySubscriptionScope = myMessageBus.NewSubscriptionScope();
 }
Exemplo n.º 21
0
 public void Setup()
 {
     _pipe  = PipeSegment.Input(PipeSegment.End <ClaimModified>());
     _scope = _pipe.NewSubscriptionScope();
     _scope.Subscribe <ClaimModified>(x => { });
 }
Exemplo n.º 22
0
		private void Dispose(bool disposing)
		{
			if (_disposed) return;
			if (disposing)
			{
				if (_scope != null)
				{
					_scope.Dispose();
					_scope = null;
				}
			}

			_disposed = true;
		}
Exemplo n.º 23
0
 public MagnumMessenger()
 {
     _messageBus        = PipeSegment.Input(PipeSegment.End());
     _subscriptionScope = _messageBus.NewSubscriptionScope();
 }
Exemplo n.º 24
0
 public void Teardown()
 {
     _subscriptionScope.Dispose();
     _subscriptionScope = null;
 }
Exemplo n.º 25
0
 public EventsProvider(Pipe eventsPipe)
 {
     Helper.GuardNotNull(eventsPipe);
     _eventsPipe = eventsPipe;
     _scope      = _eventsPipe.NewSubscriptionScope();
 }