Пример #1
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();
        }
        public void PipelineBuilding()
        {
            var             builder  = MockRepository.GenerateMock <IObjectBuilder>();
            MessagePipeline pipeline = MessagePipelineConfigurator.CreateDefault(builder, null);

            pipeline.Subscribe <MetadataConsumer>();
            pipeline.Subscribe <MetadataPConsumer>();

            PipelineViewer.Trace(pipeline);
        }
Пример #3
0
        public void Setup_Context()
        {
            _builder  = MockRepository.GenerateStub <IObjectBuilder>();
            _bus      = MockRepository.GenerateStub <IServiceBus>();
            _pipeline = MessagePipelineConfigurator.CreateDefault(_builder, _bus);
            var ef = MockRepository.GenerateStub <IEndpointFactory>();

            _address = new Uri("msmq://localhost/dru");
            _builder.Stub(x => x.GetInstance <IEndpointFactory>()).Return(ef);
            ef.Stub(x => x.GetEndpoint(_address)).Return(new NullEndpoint());

            _bus.Stub(x => x.OutboundPipeline).Return(_pipeline);
        }
Пример #4
0
        public void Setup()
        {
            _builder = MockRepository.GenerateMock <IObjectBuilder>();

            _endpoint = MockRepository.GenerateMock <IEndpoint>();
            _endpoint.Stub(x => x.Uri).Return(_uri);

            _bus = MockRepository.GenerateMock <IServiceBus>();
            _bus.Stub(x => x.Endpoint).Return(_endpoint);

            _unsubscribe = MockRepository.GenerateMock <UnsubscribeAction>();

            _subscriptionEvent = MockRepository.GenerateMock <ISubscriptionEvent>();
            _pipeline          = MessagePipelineConfigurator.CreateDefault(_builder, _bus);
            _pipeline.Configure(x => x.Register(_subscriptionEvent));
        }
Пример #5
0
        public void Should_dispatch_an_interface_via_the_pipeline()
        {
            var builder  = MockRepository.GenerateMock <IObjectBuilder>();
            var pipeline = MessagePipelineConfigurator.CreateDefault(builder, null);

            var consumer = new TestMessageConsumer <ComplaintAdded>();

            var unsubscribeAction = pipeline.Subscribe(consumer);

            var            user      = new UserImpl("Chris", "*****@*****.**");
            ComplaintAdded complaint = new ComplaintAddedImpl(user, "No toilet paper", BusinessArea.Appearance)
            {
                Body = "There was no toilet paper in the stall, forcing me to use my treasured issue of .NET Developer magazine."
            };

            pipeline.Dispatch(complaint);

            PipelineViewer.Trace(pipeline);

            consumer.ShouldHaveReceivedMessage(complaint);
        }
        public void Setup()
        {
            _builder = MockRepository.GenerateMock <IObjectBuilder>();

            _service         = MockRepository.GenerateMock <ISubscriptionService>();
            _endpointFactory = MockRepository.GenerateMock <IEndpointFactory>();

            _endpoint = MockRepository.GenerateMock <IEndpoint>();
            _endpoint.Stub(x => x.Uri).Return(_testUri);

            _bus = MockRepository.GenerateMock <IServiceBus>();
            _bus.Stub(x => x.Endpoint).Return(_endpoint);

            _pipeline = MessagePipelineConfigurator.CreateDefault(_builder, _bus);
            _bus.Stub(x => x.OutboundPipeline).Return(_pipeline);

            _consumer = new SubscriptionConsumer(_service, _endpointFactory);
            _consumer.Start(_bus);

            _remoteEndpoint = MockRepository.GenerateMock <IEndpoint>();
            _endpointFactory.Stub(x => x.GetEndpoint(_remoteUri)).Return(_remoteEndpoint);

            _service.AssertWasCalled(x => x.Register(_consumer));
        }
Пример #7
0
 public void Setup()
 {
     _builder  = MockRepository.GenerateMock <IObjectBuilder>();
     _pipeline = MessagePipelineConfigurator.CreateDefault(_builder, null);
 }