예제 #1
0
        public void Start()
        {
            if (_isStarted)
            {
                return;
            }
            _isStarted = true;

            var registry = Activator.CreateInstance(_registryType).As <FubuTransportRegistry>();

            registry.NodeName = _name;
            registry.EnableInMemoryTransport();
            registry.Services(x => x.ReplaceService <IEnvelopeHandler, ExternalNodeEnvelopeHandler>());
            TestNodes.Alterations.Each(x => x(registry));


            var container = new Container(x =>
            {
                x.ForSingletonOf <IMessageRecorder>().Use <MessageRecorder>();
                x.Forward <IMessageRecorder, IListener>();
            });

            Runtime   = FubuTransport.For(registry).StructureMap(container).Bootstrap();
            Uri       = Runtime.Factory.Get <ChannelGraph>().ReplyUriList().First();
            _recorder = Runtime.Factory.Get <IMessageRecorder>();

            // Wireup the messaging session so the MessageHistory gets notified of messages on this node
            _messageListener = Runtime.Factory.Get <IMessagingSession>();
            Bottles.Services.Messaging.EventAggregator.Messaging.AddListener(_messageListener);
        }
        internal void SpinUp()
        {
            if (!_registry.IsValueCreated)
            {
                return;
            }

            var registry = _registry.Value;
            var nodeName = ReflectionHelper.GetProperty(_expression).Name;

            registry.NodeName = nodeName;

            registry.Channel(_expression).ReadIncoming(new ThreadScheduler(2));

            registry.Handlers.DisableDefaultHandlerSource();
            registry.Handlers.Include <SourceRecordingHandler>();
            registry.AlterSettings <TransportSettings>(x => x.DebugEnabled = true);

            var container = new Container();

            // Make it all be
            var harnessSettings = InMemoryTransport.ToInMemory <HarnessSettings>();

            container.Configure(x => {
                x.For <HarnessSettings>().Use(harnessSettings);
                x.For <IListener>().Add <MessageWatcher>();
                //x.For<ILogListener>().Add(new ScenarioLogListener(nodeName));
            });

            _uri = (Uri)ReflectionHelper.GetAccessor(_expression).GetValue(harnessSettings);

            _runtime    = FubuTransport.For(registry).StructureMap(container).Bootstrap();
            _serviceBus = container.GetInstance <IServiceBus>();
        }
        public void SetUp()
        {
            TestMessageRecorder.Clear();
            FubuTransport.Reset();

            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2040/downstream".ToUri()
            };
            var lightningUri = settings.Downstream.ToLightningUri();

            var container = new Container();

            container.Inject(settings);



            _runtime = FubuTransport.For <ErrorRegistry>().StructureMap(container)
                       .Bootstrap();
            //_runtime.Factory.Get<IPersistentQueues>().ClearAll();

            theServiceBus = _runtime.Factory.Get <IServiceBus>();

            _queueManager = _runtime.Factory.Get <IPersistentQueues>().ManagerFor(lightningUri.Port, true);

            message1 = new OneMessage();

            theServiceBus.Send(message1);
        }
예제 #4
0
        public void SetUp()
        {
            // Need to do something about this.  Little ridiculous
            FubuTransport.SetupForInMemoryTesting();
            TestMessageRecorder.Clear();
            MessageHistory.ClearAll();
            InMemoryQueueManager.ClearAll();

            runtime = FubuTransport.For <DelayedRegistry>().StructureMap(new Container())
                      .Bootstrap();

            theServiceBus = runtime.Factory.Get <IServiceBus>();

            theClock = runtime.Factory.Get <ISystemTime>().As <SettableClock>();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
예제 #5
0
        public void SetUp()
        {
            FubuTransport.Reset();

            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2050/downstream".ToUri()
            };


            var container = new Container();

            container.Inject(settings);
            theClock = new SettableClock();
            container.Inject <ISystemTime>(theClock);

            _runtime = FubuTransport.For <DelayedRegistry>().StructureMap(container)
                       .Bootstrap();

            theServiceBus = _runtime.Factory.Get <IServiceBus>();
            //_runtime.Factory.Get<IPersistentQueues>().ClearAll();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            Debug.WriteLine("The current Utc time is " + theClock.UtcNow());

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
예제 #6
0
        public void FixtureSetUp()
        {
            FubuTransport.AllQueuesInMemory = true;

            runtime = FubuTransport.For <TestingJobRegistry>().StructureMap().Bootstrap();

            history        = runtime.Factory.Get <JobHistory>();
            clock          = runtime.Factory.Get <ISystemTime>().As <RewindableClock>();
            theController  = runtime.Factory.Get <IScheduledJobController>();
            thePersistence = runtime.Factory.Get <ISchedulePersistence>();
            theTimer       = runtime.Factory.Get <IJobTimer>();

            theController.Deactivate();
            theTimer.ClearAll();
            history.ClearAll();

            theStartingTime = (DateTimeOffset)DateTime.Today.AddHours(8).ToUniversalTime();

            theEndingTime = theStartingTime.AddSeconds(30);

            addTimes <Job1>(3);
            addTimes <Job2>(10);
            addTimes <Job3>(15);

            clock.Reset(theStartingTime.DateTime);

            theController.Activate();

            theController.IsActive().ShouldBeTrue();

            Thread.Sleep(32.Seconds());

            theController.Deactivate();
        }
        public void SetUp()
        {
            ImmediateJob.Executed = DelayJob.Executed = DisabledJob.Executed = 0;

            theRuntime = FubuTransport.For <PollingImmediateRegistry>()
                         .StructureMap()
                         .Bootstrap();
        }
예제 #8
0
        public void SetUp()
        {
            container = new Container(x => {
                x.For <BusSettings>().Use(theSettings);
            });

            runtime = FubuTransport.For <SubscribedRegistry>().StructureMap(container).Bootstrap();
        }
 public void PurgeQueuesJob_is_registered()
 {
     using (var runtime = FubuTransport.For <TestRegistry>().StructureMap().Bootstrap())
     {
         runtime.Factory.Get <IPollingJobs>().Any(x => x is PollingJob <PurgeQueuesJob, LightningQueueSettings>)
         .ShouldBeTrue();
     }
 }
        public FubuApplication BuildApplication()
        {
            var container = new Container(x => {
                x.For <MessageRecorder>().Singleton();
            });

            return(FubuTransport.For <WebsiteRegistry>().StructureMap(container));
        }
        public void should_throw_invalid_transport_exception_because_there_are_no_incoming_lq_transports()
        {
            string message =
                Exception <FubuException> .ShouldBeThrownBy(
                    () => { FubuTransport.For <BadTransportRegistry>().StructureMap().Bootstrap(); }).Message;

            message.ShouldContain("You must have at least one incoming Lightning Queue channel for accepting replies");
        }
예제 #12
0
        public void Startup(ISubscriptionPersistence subscriptions, ISchedulePersistence schedules)
        {
            Services(_ => {
                _.ReplaceService(subscriptions);
                _.ReplaceService(schedules);
            });

            _runtime = FubuTransport.For(this).StructureMap().Bootstrap();
        }
 public void to_in_memory_with_default_settings()
 {
     FubuTransport.SetupForInMemoryTesting <DefaultSettings>();
     using (var runtime = FubuTransport.For <DefaultRegistry>().StructureMap().Bootstrap())
     {
         var settings = InMemoryTransport.ToInMemory <NodeSettings>();
         settings.Inbound.ShouldEqual(new Uri("memory://default/inbound"));
         settings.Outbound.ShouldEqual(new Uri("memory://node/outbound"));
     }
 }
예제 #14
0
        public void must_be_a_singleton()
        {
            var container = new Container();

            using (var runtime = FubuTransport.For(x => x.EnableInMemoryTransport()).StructureMap(container).Bootstrap()
                   )
            {
                container.Model.For <ChannelGraph>().Lifecycle.ShouldBeOfType <SingletonLifecycle>();
            }
        }
예제 #15
0
        public void SetUp()
        {
            var container = new Container(x => {
                x.For <SubscriptionSettings>().Use(theSettings);
            });

            _runtime = FubuTransport.For <SubscriptionRegistry>().StructureMap(container).Bootstrap();

            theCache = _runtime.Factory.Get <ISubscriptionCache>().As <SubscriptionCache>();
        }
 public void default_reply_uri()
 {
     using (var runtime = FubuTransport.For(x => {
         x.EnableInMemoryTransport();
     }).StructureMap().Bootstrap())
     {
         runtime.Factory.Get <ChannelGraph>().ReplyChannelFor(InMemoryChannel.Protocol)
         .ShouldEqual("memory://localhost/fubu/replies".ToUri());
     }
 }
        public void the_delayed_processing_polling_job_is_registered()
        {
            FubuTransport.SetupForInMemoryTesting();

            runtime = FubuTransport.For <DelayedRegistry>().StructureMap(new Container())
                      .Bootstrap();

            runtime.Factory.Get <IPollingJobs>().Any(x => x is PollingJob <DelayedEnvelopeProcessor, TransportSettings>)
            .ShouldBeTrue();
        }
 public void can_set_the_node_name_programmatically()
 {
     using (var fubuRuntime = FubuTransport.For(x => {
         x.NodeName = "MyNode";
         x.EnableInMemoryTransport();
     }).StructureMap(new Container()).Bootstrap())
     {
         fubuRuntime
         .Factory.Get <ChannelGraph>().Name.ShouldEqual("MyNode");
     }
 }
        public void FixtureSetup()
        {
            FubuTransport.AllQueuesInMemory = true;

            theRuntime = FubuTransport.For(x => { }).StructureMap(new Container()).Bootstrap();
            graph      = theRuntime.Factory.Get <ChannelGraph>();

            var uri = graph.ReplyChannelFor(InMemoryChannel.Protocol);

            theReplyNode = graph.Single(x => x.Channel.Address == uri);
        }
        public void the_cleanup_job_is_registered()
        {
            FubuTransport.SetupForInMemoryTesting();

            using (var runtime = FubuTransport.For <InMemory.DelayedRegistry>().StructureMap(new Container())
                                 .Bootstrap())
            {
                runtime.Factory.Get <IPollingJobs>().Any(x => x is PollingJob <ExpiringListenerCleanup, TransportSettings>)
                .ShouldBeTrue();
            }
        }
예제 #21
0
        public void SetUp()
        {
            var container = new Container();

            settings = InMemoryTransport.ToInMemory <HarnessSettings>();
            container.Inject(settings);

            runtime = FubuTransport.For <RoutedRegistry>().StructureMap(container).Bootstrap();

            theRouter = runtime.Factory.Get <ISubscriptionCache>();
        }
예제 #22
0
        public void SetUp()
        {
            OneJob.Executed = TwoJob.Executed = ThreeJob.Executed = 0;

            container  = new Container();
            theRuntime = FubuTransport.For <PollingRegistry>()
                         .StructureMap(container)
                         .Bootstrap();

            Wait.Until(() => ThreeJob.Executed > 10, timeoutInMilliseconds: 6000);
        }
 public void override_the_reply_uri()
 {
     using (var runtime = FubuTransport.For(x =>
     {
         x.EnableInMemoryTransport("memory://special".ToUri());
     }).StructureMap().Bootstrap())
     {
         runtime.Factory.Get <ChannelGraph>().ReplyChannelFor(InMemoryChannel.Protocol)
         .ShouldEqual("memory://special".ToUri());
     }
 }
예제 #24
0
        public void can_register_modifiers_by_channel()
        {
            using (var runtime = FubuTransport.For <ModifyingChannelRegistry>().StructureMap().Bootstrap())
            {
                var graph = runtime.Factory.Get <ChannelGraph>();

                graph.ChannelFor <BusSettings>(x => x.Downstream).Modifiers.Single().ShouldBeOfType <FooModifier>();
                graph.ChannelFor <BusSettings>(x => x.Upstream).Modifiers.Single().ShouldBeOfType <BarModifier>();
                graph.ChannelFor <BusSettings>(x => x.Outbound).Modifiers.Any().ShouldBeFalse();
            }
        }
        public void SetUp()
        {
            FubuTransport.AllQueuesInMemory = true;

            AJob.Reset();
            BJob.Reset();
            CJob.Reset();

            theRuntime = FubuTransport.For <ScheduledJobRegistry>()
                         .StructureMap()
                         .Bootstrap();
        }
        public void able_to_derive_the_node_name_from_fubu_transport_registry_name()
        {
            using (var runtime = FubuTransport.For <CustomTransportRegistry>().StructureMap(new Container()).Bootstrap())
            {
                runtime.Factory.Get <ChannelGraph>().Name.ShouldEqual("custom");
            }

            using (var fubuRuntime = FubuTransport.For <OtherRegistry>().StructureMap(new Container()).Bootstrap())
            {
                fubuRuntime
                .Factory.Get <ChannelGraph>().Name.ShouldEqual("other");
            }
        }
        public void SetUp()
        {
            theLogger    = new SagaLogger();
            theContainer = new Container(x =>
            {
                x.For <SagaSettings>().Use(InMemoryTransport.ToInMemory <SagaSettings>());
                x.For <SagaLogger>().Use(theLogger);
                x.For <IListener>().Add <MessageWatcher>();
            });

            theRuntime = FubuTransport.For <SagaTestRegistry>().StructureMap(theContainer).Bootstrap();

            MessageHistory.ClearAll();
        }
예제 #28
0
        public void has_all_the_chains_we_expect()
        {
            var container = new Container();

            using (var runtime = FubuTransport.For <MyFirstTransport>().StructureMap(container).Bootstrap())
            {
                var graph = container.GetInstance <BehaviorGraph>();

                graph.Behaviors.Count(x => typeof(Foo1) == x.InputType()).ShouldEqual(1);
                graph.Behaviors.Count(x => typeof(Foo2) == x.InputType()).ShouldEqual(1);
                graph.Behaviors.Count(x => typeof(Foo3) == x.InputType()).ShouldEqual(1);
                graph.Behaviors.Count(x => typeof(Foo4) == x.InputType()).ShouldEqual(1);
            }
        }
예제 #29
0
        public void Start()
        {
            var registry = Activator.CreateInstance(_registryType).As <FubuTransportRegistry>();

            registry.Services(x => {
                _persistence = Subscriptions[registry.NodeName];
                x.ReplaceService <ISubscriptionPersistence>(_persistence);
                x.ReplaceService(Settings);
            });

            registry.AlterSettings <LightningQueueSettings>(x => x.Disabled = true);

            registry.EnableInMemoryTransport(_replyUri);

            _runtime = FubuTransport.For(registry).StructureMap().Bootstrap();
        }
예제 #30
0
        public void Startup(bool monitoringEnabled, ISubscriptionPersistence persistence)
        {
            AlterSettings <LightningQueueSettings>(x => x.DisableIfNoChannels = true);

            Services(_ => _sources.Each(_.AddService <IPersistentTaskSource>));
            Services(_ => _.ReplaceService(persistence));
            HealthMonitoring
            .ScheduledExecution(monitoringEnabled ? ScheduledExecution.WaitUntilInterval : ScheduledExecution.Disabled)
            .IntervalSeed(3);

            _runtime = FubuTransport.For(this).StructureMap().Bootstrap();
            var controller = _runtime.Factory.Get <IPersistentTaskController>();

            _initialTasks.Each(subject => {
                controller.TakeOwnership(subject).Wait(1.Seconds());
            });
        }