예제 #1
0
        public static Configure Distributor(this Configure config)
        {
            var msmqTransport = Configure.GetConfigSection<MsmqTransportConfig>();

            Logger = LogManager.GetLogger(Address.Local.SubScope("distributor").Queue);

            var inputQueue = Address.Local.Queue;
            var storageQueue = Address.Local.SubScope("distributor.storage");
            var controlQueue = Address.Local.SubScope("distributor.control");
            var applicativeInputQueue = Address.Local.SubScope("worker");

            config.Configurer.ConfigureComponent<ReturnAddressRewriter>(DependencyLifecycle.SingleInstance)
                .ConfigureProperty(r => r.DistributorDataQueue, Address.Local);

            NServiceBus.Distributor.MsmqWorkerAvailabilityManager.Installer.DistributorActivated = true;

            try
            {
                Address.InitializeLocalAddress(applicativeInputQueue.Queue);
            }
            catch (Exception)
            {
                //intentionally swallow
            }

            Configure.ConfigurationComplete +=
                (o, e) =>
                    {
                        var mgr = new MsmqWorkerAvailabilityManager { StorageQueue = storageQueue };

                        new ReadyMessageManager
                        {
                            WorkerAvailabilityManager = mgr,
                            NumberOfWorkerThreads = msmqTransport.NumberOfWorkerThreads,
                            ControlQueue = controlQueue
                        }.Init();

                        new DistributorBootstrapper
                            {
                                WorkerAvailabilityManager = mgr,
                                NumberOfWorkerThreads = msmqTransport.NumberOfWorkerThreads,
                                InputQueue = Address.Parse(inputQueue)
                        }.Init();
                    };

            return config;
        }
예제 #2
0
        public static Configure Distributor(this Configure config)
        {
            var msmqTransport = Configure.GetConfigSection<MsmqTransportConfig>();
            var inputQueue = GetInputQueue(msmqTransport);

            Logger = LogManager.GetLogger(inputQueue + ".distributor");

            var storageQueue = inputQueue + ".storage";
            var controlQueue = inputQueue + ".control";
            var applicativeInputQueue = inputQueue + ".worker";

            config.Configurer.ConfigureComponent<ReturnAddressRewriter>(DependencyLifecycle.SingleInstance)
                .ConfigureProperty(r => r.DistributorDataQueue, inputQueue);

            NServiceBus.Distributor.MsmqWorkerAvailabilityManager.Installer.DistributorActivated = true;

            Configure.ConfigurationComplete +=
                (o, e) =>
                    {
                        var bus = Configure.Instance.Builder.Build<UnicastBus>();
                        bus.Address = applicativeInputQueue;

                        var mgr = new MsmqWorkerAvailabilityManager { StorageQueue = storageQueue };

                        new ReadyMessageManager
                        {
                            WorkerAvailabilityManager = mgr,
                            NumberOfWorkerThreads = msmqTransport.NumberOfWorkerThreads,
                            ControlQueue = controlQueue
                        }.Init();

                        new DistributorBootstrapper
                        {
                            WorkerAvailabilityManager = mgr,
                            NumberOfWorkerThreads = msmqTransport.NumberOfWorkerThreads,
                            InputQueue = inputQueue
                        }.Init();
                    };

            return config;
        }