예제 #1
0
        public UsingRhinoQueuesBus()
        {
            if (Directory.Exists("test.esent"))
            {
                Directory.Delete("test.esent", true);
            }

            if (Directory.Exists("test.esent2"))
            {
                Directory.Delete("test.esent2", true);
            }

            if (Directory.Exists("test_subscriptions.esent"))
            {
                Directory.Delete("test_subscriptions.esent", true);
            }

            StringConsumer.Value = null;
            StringConsumer.Wait  = new ManualResetEvent(false);

            container = new WindsorContainer(new XmlInterpreter("RhinoQueues/RhinoQueues.config"));
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            container.Register(Component.For <WhenTransactionCommitErrors_ShouldNotCrash_Msmq.ConsumerEnlistingInBadTransaction>());
            container.Register(Component.For <StringConsumer>());
            container.Register(Component.For <ThrowingIntConsumer>());
            bus = container.Resolve <IStartableServiceBus>();
            bus.Start();
        }
예제 #2
0
        public UsingRhinoQueuesBusWithAlternateStorageLocation()
        {
            defaultStorageLocation   = Directory.GetCurrentDirectory();
            alternateStorageLocation = Path.Combine(Directory.GetCurrentDirectory(), "Alternate");

            storageDirectories = new[] { "test.esent", "test_subscriptions.esent" };

            if (Directory.Exists(alternateStorageLocation))
            {
                Directory.Delete(alternateStorageLocation, true);
            }

            foreach (var expectedSubDirectory in storageDirectories.Select(d => Path.Combine(defaultStorageLocation, d)))
            {
                if (Directory.Exists(expectedSubDirectory))
                {
                    Directory.Delete(expectedSubDirectory, true);
                }
            }

            var hostConfiguration = new HostConfiguration()
                                    .AddAssembly(typeof(RhinoQueuesTransport).Assembly)
                                    .StoragePath(alternateStorageLocation)
                                    .Bus("rhino.queues://localhost/test_queue2", "test")
                                    .Receive("Rhino.ServiceBus.Tests", "rhino.queues://localhost/test_queue");

            container = new WindsorContainer();
            new RhinoServiceBusConfiguration()
            .UseConfiguration(hostConfiguration.ToBusConfiguration())
            .UseCastleWindsor(container)
            .Configure();
            bus = container.Resolve <IStartableServiceBus>();
            bus.Start();
        }
        public void Enabling_performance_counters_should_result_in_performance_counters_being_created()
        {
            //This will delete an recreate the categories.
            PerformanceCategoryCreator.CreateCategories();

            var outboundIntances = new PerformanceCounterCategory(OutboundPerfomanceCounters.CATEGORY).GetInstanceNames();
            var inboundIntances = new PerformanceCounterCategory(InboundPerfomanceCounters.CATEGORY).GetInstanceNames();
            Assert.Empty(outboundIntances);
            Assert.Empty(inboundIntances);

            var hostConfiguration = new RhinoQueuesHostConfiguration()
                .EnablePerformanceCounters()
                .Bus("rhino.queues://localhost/test_queue2", "test");

            container = new WindsorContainer();
            new RhinoServiceBusConfiguration()
                .UseConfiguration(hostConfiguration.ToBusConfiguration())
                .UseCastleWindsor(container)
                .Configure();
            bus = container.Resolve<IStartableServiceBus>();
            bus.Start();

            using (var tx = new TransactionScope())
            {
                bus.Send(bus.Endpoint, "test message.");
                tx.Complete();
            }

            outboundIntances = new PerformanceCounterCategory(OutboundPerfomanceCounters.CATEGORY).GetInstanceNames();
            inboundIntances = new PerformanceCounterCategory(InboundPerfomanceCounters.CATEGORY).GetInstanceNames();

            Assert.NotEmpty(outboundIntances.Where(name => name.Contains("test_queue2")));
            Assert.NotEmpty(inboundIntances.Where(name => name.Contains("test_queue2")));
        }
        public UsingRhinoQueuesBusWithAlternateStorageLocation()
        {
            defaultStorageLocation   = Directory.GetCurrentDirectory();
            alternateStorageLocation = Path.Combine(Directory.GetCurrentDirectory(), "Alternate");

            storageDirectories = new[] { "test.esent", "test_subscriptions.esent" };

            if (Directory.Exists(alternateStorageLocation))
            {
                Directory.Delete(alternateStorageLocation, true);
            }

            foreach (var expectedSubDirectory in storageDirectories)
            {
                if (Directory.Exists(expectedSubDirectory))
                {
                    Directory.Delete(expectedSubDirectory, true);
                }
            }

            var hostConfiguration = new RhinoQueuesHostConfiguration()
                                    .StoragePath(alternateStorageLocation)
                                    .Bus("rhino.queues://localhost/test_queue2", "test")
                                    .Receive("Rhino.ServiceBus.Tests", "rhino.queues://localhost/test_queue");

            container = new WindsorContainer();
            container.Kernel.ConfigurationStore.AddFacilityConfiguration("rhino.esb", hostConfiguration.ToIConfiguration());
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            bus = container.Resolve <IStartableServiceBus>();
            bus.Start();
        }
예제 #5
0
        public UsingRhinoQueuesBus()
        {
            if (Directory.Exists("test.esent"))
            {
                Directory.Delete("test.esent", true);
            }

            if (Directory.Exists("test.esent2"))
            {
                Directory.Delete("test.esent2", true);
            }

            if (Directory.Exists("test_subscriptions.esent"))
            {
                Directory.Delete("test_subscriptions.esent", true);
            }

            StringConsumer.Value = null;
            StringConsumer.Wait  = new ManualResetEvent(false);

            container = new WindsorContainer();
            new RhinoServiceBusConfiguration()
            .UseCastleWindsor(container)
            .UseStandaloneConfigurationFile("RhinoQueues/RhinoQueues.config")
            .Configure();
            container.Register(Component.For <WhenTransactionCommitErrors_ShouldNotCrash_Msmq.ConsumerEnlistingInBadTransaction>());
            container.Register(Component.For <StringConsumer>());
            container.Register(Component.For <ThrowingIntConsumer>());
            bus = container.Resolve <IStartableServiceBus>();
            bus.Start();
        }
        public UsingRhinoQueuesBusWithAlternateStorageLocation()
        {
            defaultStorageLocation = Directory.GetCurrentDirectory();
            alternateStorageLocation = Path.Combine(Directory.GetCurrentDirectory(), "Alternate");

            storageDirectories = new[] { "test.esent", "test_subscriptions.esent" };

            if (Directory.Exists(alternateStorageLocation))
                Directory.Delete(alternateStorageLocation, true);

            foreach (var expectedSubDirectory in storageDirectories.Select(d => Path.Combine(defaultStorageLocation, d)))
            {
                if (Directory.Exists(expectedSubDirectory))
                    Directory.Delete(expectedSubDirectory, true);
            }

            var hostConfiguration = new RhinoQueuesHostConfiguration()
                .StoragePath(alternateStorageLocation)
                .Bus("rhino.queues://localhost/test_queue2", "test")
                .Receive("Rhino.ServiceBus.Tests", "rhino.queues://localhost/test_queue");

            container = new WindsorContainer();
            new RhinoServiceBusConfiguration()
                .UseConfiguration(hostConfiguration.ToBusConfiguration())
                .UseCastleWindsor(container)
                .Configure();
            bus = container.Resolve<IStartableServiceBus>();
            bus.Start();
        }
예제 #7
0
        public void Enabling_performance_counters_should_result_in_performance_counters_being_created()
        {
            //This will delete an recreate the categories.
            PerformanceCategoryCreator.CreateCategories();

            var outboundIntances = new PerformanceCounterCategory(OutboundPerfomanceCounters.CATEGORY).GetInstanceNames();
            var inboundIntances  = new PerformanceCounterCategory(InboundPerfomanceCounters.CATEGORY).GetInstanceNames();

            Assert.Empty(outboundIntances);
            Assert.Empty(inboundIntances);

            var hostConfiguration = new HostConfiguration()
                                    .EnablePerformanceCounters()
                                    .Bus("rhino.queues://localhost/test_queue2", "test");

            container = new WindsorContainer();
            new RhinoServiceBusConfiguration()
            .UseConfiguration(hostConfiguration.ToBusConfiguration())
            .UseCastleWindsor(container)
            .Configure();
            bus = container.Resolve <IStartableServiceBus>();
            bus.Start();

            using (var tx = new TransactionScope())
            {
                bus.Send(bus.Endpoint, "test message.");
                tx.Complete();
            }

            outboundIntances = new PerformanceCounterCategory(OutboundPerfomanceCounters.CATEGORY).GetInstanceNames();
            inboundIntances  = new PerformanceCounterCategory(InboundPerfomanceCounters.CATEGORY).GetInstanceNames();

            Assert.NotEmpty(outboundIntances.Where(name => name.Contains("test_queue2")));
            Assert.NotEmpty(inboundIntances.Where(name => name.Contains("test_queue2")));
        }
예제 #8
0
    private static void SendMessages(IStartableServiceBus bus, Int32 count)
    {
        Console.WriteLine("Sending {0} messages", count);

        for (Int32 n = 0; n < count; n++)
        {
            bus.Send(new TestRequest() {
                UserName = "******",
                Password = "******"
            });
        }
     
        Console.WriteLine("Completed.");
    }
예제 #9
0
    private static void SendMessages(IStartableServiceBus bus, Int32 count)
    {
        Console.WriteLine("Sending {0} messages", count);

        for (Int32 n = 0; n < count; n++)
        {
            bus.Send(new TestRequest()
            {
                UserName = "******",
                Password = "******"
            });
        }

        Console.WriteLine("Completed.");
    }
예제 #10
0
        private void InitailizeBus(string asmName)
        {
            string logfile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config");

            XmlConfigurator.ConfigureAndWatch(new FileInfo(logfile));

            assemblyName = asmName;

            CreateBootStrapper();

            log4net.GlobalContext.Properties["BusName"] = bootStrapper.GetType().Namespace;

            CreateContainer();

            InitializeContainer();

            bootStrapper.BeforeStart();

            logger.Debug("Starting bus");
            serviceBus = container.Resolve <IStartableServiceBus>();
        }
예제 #11
0
        public ReplicationFixture()
            : base(new XmlInterpreter("Primary.config"))
        {
            secondary = new WindsorContainer(new XmlInterpreter("Secondary.config"));

            secondary.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());

            secondaryBootStrapper = new DhtBootStrapper();
            secondaryBootStrapper.InitializeContainer(secondary);

            secondaryBus = secondary.Resolve<IStartableServiceBus>();
            secondaryBus.Start();

            secondaryBootStrapper.AfterStart();

            tertiary = new WindsorContainer(new XmlInterpreter("Tertiary.config"));
            tertiary.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());

            tertiaryBootStrapper = new DhtBootStrapper();
            tertiaryBootStrapper.InitializeContainer(tertiary);

            tertiaryBus = tertiary.Resolve<IStartableServiceBus>();
            tertiaryBus.Start();

            tertiaryBootStrapper.AfterStart();

            buses = new[]
            {
                bus,
                secondaryBus,
                tertiaryBus,
            };

            bootStrappers = new[]
            {
                bootStrapper,
                secondaryBootStrapper,
                tertiaryBootStrapper,
            };
        }
예제 #12
0
        public DhtTestBase(IConfigurationInterpreter interpreter)
        {
            EnsureQueueExistsAndIsEmpty("msmq://localhost/dht_test.replication");
            EnsureQueueExistsAndIsEmpty("msmq://localhost/dht_test.replication2");
            EnsureQueueExistsAndIsEmpty("msmq://localhost/dht_test.replication3");

            Delete("cache.esent");
            Delete("cache1.esent");
            Delete("cache2.esent");
            Delete("cache3.esent");
            Delete("test.esent");

            container = new WindsorContainer(interpreter);
            var facility = new RhinoServiceBusFacility();
            bootStrapper = new DhtBootStrapper();
            bootStrapper.ConfigureBusFacility(facility);

            container.Kernel.AddFacility("rhino.esb", facility);

            bus = container.Resolve<IStartableServiceBus>();

            bootStrapper.InitializeContainer(container);

            bus.Start();

            bootStrapper.AfterStart();

            metaDataUrl = new Uri("net.tcp://localhost:8128/dht.metadata");
            client = new DistributedHashTableClient(new Node
            {
                Primary = new NodeUri
                {
                    Sync = metaDataUrl
                }
            });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RhinoWrapServiceBusAbstractor"/> class.
 /// </summary>
 /// <param name="serviceLocator">The service locator.</param>
 /// <param name="bus">The bus.</param>
 public RhinoWrapServiceBusAbstractor(IServiceLocator serviceLocator, IStartableServiceBus bus)
     : base(serviceLocator, bus)
 {
 }
		public Startable(IStartableServiceBus startableBus)
		{
			_startableBus = startableBus;
		}
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RhinoServiceBusAbstractor"/> class.
 /// </summary>
 /// <param name="serviceLocator">The service locator.</param>
 /// <param name="bus">The bus.</param>
 public RhinoServiceBusAbstractor(IServiceLocator serviceLocator, IStartableServiceBus bus)
     : this(serviceLocator, (IServiceBus)bus)
 {
     bus.Start();
 }
예제 #16
0
 public Startable(IStartableServiceBus startableBus)
 {
     _startableBus = startableBus;
 }