Inheritance: INimbusConfiguration
コード例 #1
0
 public static BusBuilderConfiguration WithDefaultTimeout(this BusBuilderConfiguration configuration, TimeSpan defaultTimeout)
 {
     configuration.DefaultTimeout = new DefaultTimeoutSetting {
         Value = defaultTimeout
     };
     return(configuration);
 }
コード例 #2
0
 public static BusBuilderConfiguration WithGlobalPrefix(this BusBuilderConfiguration configuration, string globalPrefix)
 {
     configuration.GlobalPrefix = new GlobalPrefixSetting {
         Value = globalPrefix
     };
     return(configuration);
 }
コード例 #3
0
 public static BusBuilderConfiguration WithDefaultConcurrentHandlerLimit(this BusBuilderConfiguration configuration, int defaultConcurrentHandlerLimit)
 {
     configuration.ConcurrentHandlerLimit = new ConcurrentHandlerLimitSetting {
         Value = defaultConcurrentHandlerLimit
     };
     return(configuration);
 }
コード例 #4
0
 public static BusBuilderConfiguration WithHeartbeatInterval(this BusBuilderConfiguration configuration, TimeSpan heartbeatInterval)
 {
     configuration.HeartbeatInterval = new HeartbeatIntervalSetting {
         Value = heartbeatInterval
     };
     return(configuration);
 }
コード例 #5
0
 public static BusBuilderConfiguration WithConnectionString(this BusBuilderConfiguration configuration, string connectionString)
 {
     configuration.ConnectionString = new ConnectionStringSetting {
         Value = connectionString
     };
     return(configuration);
 }
コード例 #6
0
 public static BusBuilderConfiguration WithDefaultMessageLockDuration(this BusBuilderConfiguration configuration, TimeSpan defaultLockDuration)
 {
     configuration.DefaultMessageLockDuration = new DefaultMessageLockDurationSetting {
         Value = defaultLockDuration
     };
     return(configuration);
 }
コード例 #7
0
 public static BusBuilderConfiguration WithAutofacDefaults(this BusBuilderConfiguration configuration, IComponentContext componentContext)
 {
     return(configuration
            .WithTypesFrom(componentContext.Resolve <ITypeProvider>())
            .WithDependencyResolver(componentContext.Resolve <IDependencyResolver>())
            );
 }
コード例 #8
0
 public static BusBuilderConfiguration WithServerConnectionCount(this BusBuilderConfiguration configuration, int serverConnectionCount)
 {
     configuration.ServerConnectionCount = new ServerConnectionCountSetting {
         Value = serverConnectionCount
     };
     return(configuration);
 }
コード例 #9
0
 public static BusBuilderConfiguration WithDefaultMessageTimeToLive(this BusBuilderConfiguration configuration, TimeSpan timeToLive)
 {
     configuration.DefaultMessageTimeToLive = new DefaultMessageTimeToLiveSetting {
         Value = timeToLive
     };
     return(configuration);
 }
コード例 #10
0
 public static BusBuilderConfiguration WithMaxDeliveryAttempts(this BusBuilderConfiguration configuration, int maxDeliveryAttempts)
 {
     configuration.MaxDeliveryAttempts = new MaxDeliveryAttemptSetting {
         Value = maxDeliveryAttempts
     };
     return(configuration);
 }
コード例 #11
0
 public static BusBuilderConfiguration WithMinimumThreadPoolThreads(this BusBuilderConfiguration configuration, int minimumThreadPoolThreads)
 {
     configuration.MinimumThreadPoolThreads = new MinimumThreadPoolThreadsSetting {
         Value = minimumThreadPoolThreads
     };
     return(configuration);
 }
コード例 #12
0
 public static BusBuilderConfiguration WithAutoDeleteOnIdle(this BusBuilderConfiguration configuration, TimeSpan autoDeleteOnIdle)
 {
     configuration.AutoDeleteOnIdle = new AutoDeleteOnIdleSetting {
         Value = autoDeleteOnIdle
     };
     return(configuration);
 }
コード例 #13
0
 public static BusBuilderConfiguration WithGlobalOutboundInterceptorTypes(this BusBuilderConfiguration configuration, params Type[] interceptorTypes)
 {
     configuration.GlobalOutboundInterceptorTypes = new GlobalOutboundInterceptorTypesSetting {
         Value = interceptorTypes
     };
     return(configuration);
 }
コード例 #14
0
ファイル: BusBuilder.cs プロジェクト: nblumhardt/Nimbus
 private static void CreateCommandMessagePumps(BusBuilderConfiguration configuration, MessagingFactory messagingFactory, List<IMessagePump> messagePumps)
 {
     foreach (var commandType in configuration.CommandTypes)
     {
         var pump = new CommandMessagePump(messagingFactory, configuration.CommandBroker, commandType, configuration.Logger);
         messagePumps.Add(pump);
     }
 }
コード例 #15
0
ファイル: BusBuilder.cs プロジェクト: DamianMac/Nimbus
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var logger = configuration.Logger;

            logger.Debug("Constructing bus...");

            configuration.AssertConfigurationIsValid();

            var container = new PoorMansIoC();

            container.RegisterPropertiesFromConfigurationObject(configuration);

            logger.Debug("Creating message pumps...");
            var messagePumpsManager = new MessagePumpsManager(
                container.Resolve <ResponseMessagePumpFactory>().Create(),
                container.Resolve <RequestMessagePumpsFactory>().CreateAll(),
                container.Resolve <CommandMessagePumpsFactory>().CreateAll(),
                container.Resolve <MulticastRequestMessagePumpsFactory>().CreateAll(),
                container.Resolve <MulticastEventMessagePumpsFactory>().CreateAll(),
                container.Resolve <CompetingEventMessagePumpsFactory>().CreateAll());

            logger.Debug("Message pumps are all created.");

            var bus = container.ResolveWithOverrides <Bus>(messagePumpsManager);

            container.Resolve <PropertyInjector>().Bus = bus;

            bus.Starting += (s, e) =>
            {
                Task.Run(async() =>
                {
                    try
                    {
                        await container.Resolve <INimbusTransport>().TestConnection();
                        await CleanNamespace(container, logger);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex, "Failed to establish connection to underlying transport: {Message}", ex.Message);
                        throw;
                    }
                }).Wait();
            };

            bus.Disposing += (s, e) =>
            {
                Task.Run(async() =>
                {
                    await CleanNamespace(container, logger);
                    container.Dispose();
                }).Wait();
            };

            logger.Info("Bus built. Job done!");

            return(bus);
        }
コード例 #16
0
 public static BusBuilderConfiguration WithDefaults(this BusBuilderConfiguration configuration, ITypeProvider typeProvider)
 {
     return(configuration
            .WithTypesFrom(typeProvider)
            .WithDependencyResolver(new DependencyResolver(typeProvider))
            .WithRouter(new DestinationPerMessageTypeRouter())
            .WithCompressor(new NullCompressor())
            .WithLogger(new NullLogger())
            );
 }
コード例 #17
0
 /// <summary>
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="applicationName">
 ///     This should be unique for your application (e.g. Foo.exe) but should be the same across
 ///     all instances of your application.
 /// </param>
 /// <param name="instanceName">
 ///     This should be unique across ALL instances of your application. Use your hostname if you're
 ///     stuck.
 /// </param>
 /// <returns></returns>
 public static BusBuilderConfiguration WithNames(this BusBuilderConfiguration configuration, string applicationName, string instanceName)
 {
     configuration.ApplicationName = new ApplicationNameSetting {
         Value = applicationName
     };
     configuration.InstanceName = new InstanceNameSetting {
         Value = instanceName
     };
     return(configuration);
 }
コード例 #18
0
ファイル: BusBuilder.cs プロジェクト: NimbusAPI/Nimbus
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var logger = configuration.Logger;
            logger.Debug("Constructing bus...");

            configuration.AssertConfigurationIsValid();

            var container = new PoorMansIoC();
            container.RegisterPropertiesFromConfigurationObject(configuration);

            logger.Debug("Creating message pumps...");
            var messagePumpsManager = new MessagePumpsManager(
                container.Resolve<ResponseMessagePumpFactory>().Create(),
                container.Resolve<RequestMessagePumpsFactory>().CreateAll(),
                container.Resolve<CommandMessagePumpsFactory>().CreateAll(),
                container.Resolve<MulticastRequestMessagePumpsFactory>().CreateAll(),
                container.Resolve<MulticastEventMessagePumpsFactory>().CreateAll(),
                container.Resolve<CompetingEventMessagePumpsFactory>().CreateAll());

            logger.Debug("Message pumps are all created.");

            var bus = container.ResolveWithOverrides<Bus>(messagePumpsManager);
            container.Resolve<PropertyInjector>().Bus = bus;

            bus.Starting += (s, e) =>
                            {
                                Task.Run(async () =>
                                               {
                                                   try
                                                   {
                                                       await container.Resolve<INimbusTransport>().TestConnection();
                                                       await CleanNamespace(container, logger);
                                                   }
                                                   catch (Exception ex)
                                                   {
                                                       logger.Error(ex, "Failed to establish connection to underlying transport: {Message}", ex.Message);
                                                       throw;
                                                   }
                                               }).Wait();
                            };

            bus.Disposing += (s, e) =>
                             {
                                 Task.Run(async () =>
                                                {
                                                    await CleanNamespace(container, logger);
                                                    container.Dispose();
                                                }).Wait();
                             };

            logger.Info("Bus built. Job done!");

            return bus;
        }
コード例 #19
0
ファイル: BusBuilder.cs プロジェクト: nblumhardt/Nimbus
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var replyQueueName = string.Format("InputQueue.{0}.{1}", configuration.ApplicationName, configuration.InstanceName);

            var namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);
            var messagingFactory = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);

            var messagePumps = new List<IMessagePump>();

            var queueManager = new QueueManager(namespaceManager, messagingFactory, configuration.MaxDeliveryAttempts);

            var clock = new SystemClock();
            var requestResponseCorrelator = new RequestResponseCorrelator(clock);

            var messageSenderFactory = new MessageSenderFactory(messagingFactory);
            var topicClientFactory = new TopicClientFactory(messagingFactory);
            var commandSender = new BusCommandSender(messageSenderFactory);
            var requestSender = new BusRequestSender(messageSenderFactory, replyQueueName, requestResponseCorrelator, clock, configuration.DefaultTimeout);
            var multicastRequestSender = new BusMulticastRequestSender(topicClientFactory, replyQueueName, requestResponseCorrelator, clock);
            var eventSender = new BusEventSender(topicClientFactory);

            if (configuration.Debugging.RemoveAllExistingNamespaceElements)
            {
                RemoveAllExistingNamespaceElements(namespaceManager);
            }

            var queueCreationTasks = new[]
            {
                Task.Run(() => CreateMyInputQueue(queueManager, replyQueueName)),
                Task.Run(() => CreateCommandQueues(configuration, queueManager)),
                Task.Run(() => CreateRequestQueues(configuration, queueManager)),
                Task.Run(() => CreateMulticastRequestTopics(configuration, queueManager)),
                Task.Run(() => CreateEventTopics(configuration, queueManager)),
            };
            Task.WaitAll(queueCreationTasks);

            //FIXME do these in parallel
            CreateResponseMessagePump(configuration, messagingFactory, replyQueueName, requestResponseCorrelator, messagePumps);
            CreateCommandMessagePumps(configuration, messagingFactory, messagePumps);
            CreateRequestMessagePumps(configuration, messagingFactory, messagePumps);
            CreateMulticastRequestMessagePumps(configuration, queueManager, messagingFactory, messagePumps);
            CreateMulticastEventMessagePumps(configuration, queueManager, messagingFactory, messagePumps);
            CreateCompetingEventMessagePumps(configuration, queueManager, messagingFactory, messagePumps);

            var commandDeadLetterQueue = new DeadLetterQueue(queueManager);
            var requestDeadLetterQueue = new DeadLetterQueue(queueManager);
            var deadLetterQueues = new DeadLetterQueues(commandDeadLetterQueue, requestDeadLetterQueue);

            var bus = new Bus(commandSender, requestSender, multicastRequestSender, eventSender, messagePumps, deadLetterQueues);
            return bus;
        }
コード例 #20
0
ファイル: BusBuilder.cs プロジェクト: shingi/Nimbus
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var logger = configuration.Logger;
            logger.Debug("Constructing bus...");

            var container = new PoorMansIoC();

            foreach (var prop in configuration.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance))
            {
                var value = prop.GetValue(configuration);
                if (value == null) continue;
                container.Register(value);
            }

            container.Register<Func<NamespaceManager>>(c => () => NamespaceManager.CreateFromConnectionString(c.Resolve<ConnectionStringSetting>()));
            container.Register<Func<MessagingFactory>>(c => () => MessagingFactory.CreateFromConnectionString(c.Resolve<ConnectionStringSetting>()));

            if (configuration.Debugging.RemoveAllExistingNamespaceElements)
            {
                RemoveAllExistingNamespaceElements(container.Resolve<Func<NamespaceManager>>(), logger);
            }

            logger.Debug("Creating message pumps and subscriptions.");
            var messagePumps = new List<IMessagePump>();
            messagePumps.Add(container.Resolve<ResponseMessagePumpFactory>().Create());
            messagePumps.AddRange(container.Resolve<CommandMessagePumpsFactory>().CreateAll());
            messagePumps.AddRange(container.Resolve<RequestMessagePumpsFactory>().CreateAll());
            messagePumps.AddRange(container.Resolve<MulticastRequestMessagePumpsFactory>().CreateAll());
            messagePumps.AddRange(container.Resolve<MulticastEventMessagePumpsFactory>().CreateAll());
            messagePumps.AddRange(container.Resolve<CompetingEventMessagePumpsFactory>().CreateAll());
            logger.Debug("Message pumps and subscriptions are all created.");

            var bus = new Bus(container.Resolve<ILogger>(),
                              container.Resolve<ICommandSender>(),
                              container.Resolve<IRequestSender>(),
                              container.Resolve<IMulticastRequestSender>(),
                              container.Resolve<IEventSender>(),
                              messagePumps,
                              container.Resolve<DeadLetterQueues>());

            bus.Disposing += (sender, args) => container.Dispose();

            logger.Debug("Bus built. Job done!");

            return bus;
        }
コード例 #21
0
ファイル: BusBuilder.cs プロジェクト: KodrAus/Nimbus
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var logger = configuration.Logger;

            logger.Debug("Constructing bus...");

            configuration.AssertConfigurationIsValid();

            var container = new PoorMansIoC();

            container.RegisterPropertiesFromConfigurationObject(configuration);

            logger.Debug("Creating message pumps...");
            var messagePumpsManager = new MessagePumpsManager(
                container.Resolve <ResponseMessagePumpFactory>().Create(),
                container.Resolve <RequestMessagePumpsFactory>().CreateAll(),
                container.Resolve <CommandMessagePumpsFactory>().CreateAll(),
                container.Resolve <MulticastRequestMessagePumpsFactory>().CreateAll(),
                container.Resolve <MulticastEventMessagePumpsFactory>().CreateAll(),
                container.Resolve <CompetingEventMessagePumpsFactory>().CreateAll());

            logger.Debug("Message pumps are all created.");

            var bus = container.ResolveWithOverrides <Bus>(messagePumpsManager);

            container.Resolve <PropertyInjector>().Bus = bus;

            bus.Starting += delegate
            {
                container.Resolve <INimbusTransport>().TestConnection().Wait();

                var removeAllExistingElements = container.Resolve <RemoveAllExistingNamespaceElementsSetting>();
                if (removeAllExistingElements)
                {
                    logger.Debug("Removing all existing namespace elements. IMPORTANT: This should only be done in your regression test suites.");
                    var cleanser = container.Resolve <INamespaceCleanser>();
                    cleanser.RemoveAllExistingNamespaceElements().Wait();
                }
            };
            bus.Disposing += delegate { container.Dispose(); };

            logger.Info("Bus built. Job done!");

            return(bus);
        }
コード例 #22
0
ファイル: BusBuilder.cs プロジェクト: fenix2222/Nimbus
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var logger = configuration.Logger;
            logger.Debug("Constructing bus...");

            configuration.AssertConfigurationIsValid();

            var container = new PoorMansIoC();
            container.RegisterPropertiesFromConfigurationObject(configuration);

            logger.Debug("Creating message pumps...");
            var messagePumpsManager = new MessagePumpsManager(
                container.Resolve<ResponseMessagePumpFactory>().Create(),
                container.Resolve<RequestMessagePumpsFactory>().CreateAll(),
                container.Resolve<CommandMessagePumpsFactory>().CreateAll(),
                container.Resolve<MulticastRequestMessagePumpsFactory>().CreateAll(),
                container.Resolve<MulticastEventMessagePumpsFactory>().CreateAll(),
                container.Resolve<CompetingEventMessagePumpsFactory>().CreateAll());

            logger.Debug("Message pumps are all created.");

            var bus = container.ResolveWithOverrides<Bus>(messagePumpsManager);
            container.Resolve<PropertyInjector>().Bus = bus;

            bus.Starting += delegate
                            {
                                container.Resolve<INimbusTransport>().TestConnection().Wait();

                                var removeAllExistingElements = container.Resolve<RemoveAllExistingNamespaceElementsSetting>();
                                if (removeAllExistingElements)
                                {
                                    logger.Debug("Removing all existing namespace elements. IMPORTANT: This should only be done in your regression test suites.");
                                    var cleanser = container.Resolve<INamespaceCleanser>();
                                    cleanser.RemoveAllExistingNamespaceElements().Wait();
                                }
                            };
            bus.Disposing += delegate { container.Dispose(); };

            logger.Info("Bus built. Job done!");

            return bus;
        }
コード例 #23
0
 public static BusBuilderConfiguration WithDebugOptions(this BusBuilderConfiguration configuration,
                                                        Func <DebugConfiguration, DebugConfiguration> debugConfiguration)
 {
     debugConfiguration(configuration.Debug);
     return(configuration);
 }
コード例 #24
0
ファイル: BusBuilder.cs プロジェクト: nhuhuynh/Nimbus
        private static void CreateMulticastEventMessagePumps(BusBuilderConfiguration configuration,
                                                             IQueueManager queueManager,
                                                             MessagingFactory messagingFactory,
                                                             ICollection<IMessagePump> messagePumps,
                                                             ILogger logger)
        {
            logger.Debug("Creating multicast event message pumps");

            var eventTypes = configuration.MulticastEventHandlerTypes.SelectMany(ht => ht.GetGenericInterfacesClosing(typeof (IHandleMulticastEvent<>)))
                                          .Select(gi => gi.GetGenericArguments().Single())
                                          .OrderBy(t => t.FullName)
                                          .Distinct()
                                          .ToArray();

            foreach (var eventType in eventTypes)
            {
                logger.Debug("Registering Message Pump for Event type {0}", eventType.Name);

                var myInstanceSubscriptionName = String.Format("{0}.{1}", configuration.InstanceName, configuration.ApplicationName);
                queueManager.EnsureSubscriptionExists(eventType, myInstanceSubscriptionName);
                var pump = new MulticastEventMessagePump(messagingFactory, configuration.MulticastEventBroker, eventType, myInstanceSubscriptionName, configuration.Logger, configuration.DefaultBatchSize);
                messagePumps.Add(pump);
            }
        }
コード例 #25
0
        public static BusBuilderConfiguration WithConnectionStringFromFile(this BusBuilderConfiguration configuration, string filename)
        {
            var connectionString = File.ReadAllText(filename).Trim();

            return(configuration.WithConnectionString(connectionString));
        }
コード例 #26
0
ファイル: BusBuilder.cs プロジェクト: nhuhuynh/Nimbus
        private static void CreateRequestQueues(BusBuilderConfiguration configuration, QueueManager queueManager, ILogger logger)
        {
            logger.Debug("Creating request queues");

            configuration.RequestTypes
                         .AsParallel()
                         .Do(queueManager.EnsureQueueExists)
                         .Done();
        }
コード例 #27
0
 public static BusBuilderConfiguration WithDeliveryRetryStrategy(this BusBuilderConfiguration configuration, IDeliveryRetryStrategy deliveryRetryStrategy)
 {
     configuration.DeliveryRetryStrategy = deliveryRetryStrategy;
     return(configuration);
 }
コード例 #28
0
 public static BusBuilderConfiguration WithDependencyResolver(this BusBuilderConfiguration configuration, IDependencyResolver dependencyResolver)
 {
     configuration.DependencyResolver = dependencyResolver;
     return(configuration);
 }
コード例 #29
0
ファイル: BusBuilder.cs プロジェクト: nhuhuynh/Nimbus
        private static void CreateRequestMessagePumps(BusBuilderConfiguration configuration, MessagingFactory messagingFactory, List<IMessagePump> messagePumps, ILogger logger)
        {
            logger.Debug("Creating request message pumps");


            var requestTypes = configuration.RequestHandlerTypes.SelectMany(ht => ht.GetGenericInterfacesClosing(typeof(IHandleRequest<,>)))
                                            .Select(gi => gi.GetGenericArguments().First())
                                            .OrderBy(t => t.FullName)
                                            .Distinct()
                                            .ToArray();

            foreach (var requestType in requestTypes)
            {
                logger.Debug("Registering Message Pump for Request type {0}", requestType.Name);
                var pump = new RequestMessagePump(messagingFactory, configuration.RequestBroker, requestType, configuration.Logger, configuration.DefaultBatchSize);
                messagePumps.Add(pump);
            }

  
        }
コード例 #30
0
ファイル: BusBuilder.cs プロジェクト: nblumhardt/Nimbus
 private static void CreateRequestMessagePumps(BusBuilderConfiguration configuration, MessagingFactory messagingFactory, List<IMessagePump> messagePumps)
 {
     foreach (var requestType in configuration.RequestTypes)
     {
         var pump = new RequestMessagePump(messagingFactory, configuration.RequestBroker, requestType, configuration.Logger);
         messagePumps.Add(pump);
     }
 }
コード例 #31
0
ファイル: BusBuilder.cs プロジェクト: nblumhardt/Nimbus
 private static void CreateResponseMessagePump(BusBuilderConfiguration configuration,
                                               MessagingFactory messagingFactory,
                                               string replyQueueName,
                                               RequestResponseCorrelator requestResponseCorrelator,
                                               ICollection<IMessagePump> messagePumps)
 {
     var responseMessagePump = new ResponseMessagePump(messagingFactory, replyQueueName, requestResponseCorrelator, configuration.Logger);
     messagePumps.Add(responseMessagePump);
 }
コード例 #32
0
 public static BusBuilderConfiguration WithSerializer(this BusBuilderConfiguration configuration, ISerializer serializer)
 {
     configuration.Serializer = serializer;
     return(configuration);
 }
コード例 #33
0
ファイル: BusBuilder.cs プロジェクト: joshka/Nimbus
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var logger = configuration.Logger;
            logger.Debug("Constructing bus...");

            var container = new PoorMansIoC();

            RegisterPropertiesFromConfigurationObject(container, configuration);
            RegisterPropertiesFromConfigurationObject(container, configuration.LargeMessageStorageConfiguration);
            RegisterPropertiesFromConfigurationObject(container, configuration.Debugging);

            var namespaceManagerRoundRobin = new RoundRobin<NamespaceManager>(
                container.Resolve<ServerConnectionCountSetting>(),
                () =>
                {
                    var namespaceManager = NamespaceManager.CreateFromConnectionString(container.Resolve<ConnectionStringSetting>());
                    namespaceManager.Settings.OperationTimeout = TimeSpan.FromSeconds(120);
                    return namespaceManager;
                },
                nsm => false,
                nsm => { });

            container.Register<Func<NamespaceManager>>(c => namespaceManagerRoundRobin.GetNext);

            var messagingFactoryRoundRobin = new RoundRobin<MessagingFactory>(
                container.Resolve<ServerConnectionCountSetting>(),
                () =>
                {
                    var messagingFactory = MessagingFactory.CreateFromConnectionString(container.Resolve<ConnectionStringSetting>());
                    messagingFactory.PrefetchCount = container.Resolve<ConcurrentHandlerLimitSetting>();
                    return messagingFactory;
                },
                mf => mf.IsBorked(),
                mf => { });

            container.Register<Func<MessagingFactory>>(c => messagingFactoryRoundRobin.GetNext);

            if (configuration.Debugging.RemoveAllExistingNamespaceElements)
            {
                var namespaceCleanser = container.Resolve<NamespaceCleanser>();
                namespaceCleanser.RemoveAllExistingNamespaceElements().Wait();
            }

            logger.Debug("Creating message pumps...");

            var messagePumps = new MessagePumpsManager(
                container.Resolve<ResponseMessagePumpFactory>().Create(),
                container.Resolve<RequestMessagePumpsFactory>().CreateAll(),
                container.Resolve<CommandMessagePumpsFactory>().CreateAll(),
                container.Resolve<MulticastRequestMessagePumpsFactory>().CreateAll(),
                container.Resolve<MulticastEventMessagePumpsFactory>().CreateAll(),
                container.Resolve<CompetingEventMessagePumpsFactory>().CreateAll(),
                container.Resolve<INimbusTaskFactory>());

            logger.Debug("Message pumps are all created.");

            var bus = new Bus(container.Resolve<ILogger>(),
                              container.Resolve<ICommandSender>(),
                              container.Resolve<IRequestSender>(),
                              container.Resolve<IMulticastRequestSender>(),
                              container.Resolve<IEventSender>(),
                              messagePumps,
                              container.Resolve<DeadLetterQueues>(),
                              container.Resolve<INimbusTaskFactory>(),
                              container.Resolve<IHeartbeat>());

            bus.Starting += delegate
                            {
                                container.Resolve<AzureQueueManager>().WarmUp();
                                container.Resolve<PropertyInjector>().Bus = bus;
                            };
            bus.Disposing += delegate { container.Dispose(); };

            logger.Info("Bus built. Job done!");

            return bus;
        }
コード例 #34
0
ファイル: BusBuilder.cs プロジェクト: nblumhardt/Nimbus
 private static void CreateCommandQueues(BusBuilderConfiguration configuration, QueueManager queueManager)
 {
     configuration.CommandTypes
                  .AsParallel()
                  .Do(queueManager.EnsureQueueExists)
                  .Done();
 }
コード例 #35
0
ファイル: BusBuilder.cs プロジェクト: nblumhardt/Nimbus
        private static void CreateCompetingEventMessagePumps(BusBuilderConfiguration configuration,
                                                             IQueueManager queueManager,
                                                             MessagingFactory messagingFactory,
                                                             ICollection<IMessagePump> messagePumps)
        {
            var eventTypes = configuration.CompetingEventHandlerTypes.SelectMany(ht => ht.GetGenericInterfacesClosing(typeof (IHandleCompetingEvent<>)))
                                          .Select(gi => gi.GetGenericArguments().Single())
                                          .OrderBy(t => t.FullName)
                                          .Distinct()
                                          .ToArray();

            foreach (var eventType in eventTypes)
            {
                var applicationSharedSubscriptionName = String.Format("{0}", configuration.ApplicationName);
                queueManager.EnsureSubscriptionExists(eventType, applicationSharedSubscriptionName);
                var pump = new CompetingEventMessagePump(messagingFactory, configuration.CompetingEventBroker, eventType, applicationSharedSubscriptionName, configuration.Logger);
                messagePumps.Add(pump);
            }
        }
コード例 #36
0
ファイル: BusBuilder.cs プロジェクト: teyc/Nimbus_v2
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var logger = configuration.Logger;

            logger.Debug("Constructing bus...");

            var container = new PoorMansIoC();

            RegisterPropertiesFromConfigurationObject(container, configuration);
            RegisterPropertiesFromConfigurationObject(container, configuration.LargeMessageStorageConfiguration);
            RegisterPropertiesFromConfigurationObject(container, configuration.Debugging);

            var namespaceManagerRoundRobin = new RoundRobin <NamespaceManager>(
                container.Resolve <ServerConnectionCountSetting>(),
                () =>
            {
                var namespaceManager = NamespaceManager.CreateFromConnectionString(container.Resolve <ConnectionStringSetting>());
                namespaceManager.Settings.OperationTimeout = TimeSpan.FromSeconds(120);
                return(namespaceManager);
            },
                nsm => false,
                nsm => { });

            container.Register <Func <NamespaceManager> >(c => namespaceManagerRoundRobin.GetNext);

            var messagingFactoryRoundRobin = new RoundRobin <MessagingFactory>(
                container.Resolve <ServerConnectionCountSetting>(),
                () =>
            {
                var messagingFactory           = MessagingFactory.CreateFromConnectionString(container.Resolve <ConnectionStringSetting>());
                messagingFactory.PrefetchCount = container.Resolve <ConcurrentHandlerLimitSetting>();
                return(messagingFactory);
            },
                mf => mf.IsBorked(),
                mf => { });

            container.Register <Func <MessagingFactory> >(c => messagingFactoryRoundRobin.GetNext);

            if (configuration.Debugging.RemoveAllExistingNamespaceElements)
            {
                var namespaceCleanser = container.Resolve <NamespaceCleanser>();
                namespaceCleanser.RemoveAllExistingNamespaceElements().Wait();
            }

            logger.Debug("Creating message pumps...");

            var messagePumps = new MessagePumpsManager(
                container.Resolve <ResponseMessagePumpFactory>().Create(),
                container.Resolve <RequestMessagePumpsFactory>().CreateAll(),
                container.Resolve <CommandMessagePumpsFactory>().CreateAll(),
                container.Resolve <MulticastRequestMessagePumpsFactory>().CreateAll(),
                container.Resolve <MulticastEventMessagePumpsFactory>().CreateAll(),
                container.Resolve <CompetingEventMessagePumpsFactory>().CreateAll(),
                container.Resolve <INimbusTaskFactory>());

            logger.Debug("Message pumps are all created.");

            var bus = new Bus(container.Resolve <ILogger>(),
                              container.Resolve <ICommandSender>(),
                              container.Resolve <IRequestSender>(),
                              container.Resolve <IMulticastRequestSender>(),
                              container.Resolve <IEventSender>(),
                              messagePumps,
                              container.Resolve <DeadLetterQueues>(),
                              container.Resolve <INimbusTaskFactory>(),
                              container.Resolve <IHeartbeat>());

            bus.Starting += delegate
            {
                container.Resolve <AzureQueueManager>().WarmUp();
                container.Resolve <PropertyInjector>().Bus = bus;
            };
            bus.Disposing += delegate { container.Dispose(); };

            logger.Info("Bus built. Job done!");

            return(bus);
        }
コード例 #37
0
 public static BusBuilderConfiguration WithTransport(this BusBuilderConfiguration configuration, TransportConfiguration transportConfiguration)
 {
     configuration.Transport = transportConfiguration;
     return(configuration);
 }
コード例 #38
0
ファイル: BusBuilder.cs プロジェクト: nhuhuynh/Nimbus
        internal static Bus Build(BusBuilderConfiguration configuration)
        {
            var logger = configuration.Logger;

            logger.Debug("Constructing bus...");

            var replyQueueName = string.Format("InputQueue.{0}.{1}", configuration.ApplicationName, configuration.InstanceName);

            var namespaceManager = NamespaceManager.CreateFromConnectionString(configuration.ConnectionString);
            var versionInfo = namespaceManager.GetVersionInfo();

            var messagingFactory = MessagingFactory.CreateFromConnectionString(configuration.ConnectionString);

            var messagePumps = new List<IMessagePump>();

            var queueManager = new QueueManager(namespaceManager, messagingFactory, configuration.MaxDeliveryAttempts, logger);

            var clock = new SystemClock();
            var requestResponseCorrelator = new RequestResponseCorrelator(clock, logger);

            var messageSenderFactory = new MessageSenderFactory(messagingFactory);
            var topicClientFactory = new TopicClientFactory(messagingFactory);
            var commandSender = new BusCommandSender(messageSenderFactory, clock, configuration.CommandTypes);
            var requestSender = new BusRequestSender(messageSenderFactory, replyQueueName, requestResponseCorrelator, clock, configuration.DefaultTimeout, configuration.RequestTypes, logger);
            var multicastRequestSender = new BusMulticastRequestSender(topicClientFactory, replyQueueName, requestResponseCorrelator, clock, configuration.RequestTypes);
            var eventSender = new BusEventSender(topicClientFactory, configuration.EventTypes);

            if (configuration.Debugging.RemoveAllExistingNamespaceElements)
            {
                RemoveAllExistingNamespaceElements(namespaceManager, logger);
            }

            logger.Debug("Creating queues and topics");

            var queueCreationTasks =
                new[]
                {
                    Task.Run(() => CreateMyInputQueue(queueManager, replyQueueName, logger)),
                    Task.Run(() => CreateCommandQueues(configuration, queueManager, logger)),
                    Task.Run(() => CreateRequestQueues(configuration, queueManager, logger)),
                    Task.Run(() => CreateMulticastRequestTopics(configuration, queueManager, logger)),
                    Task.Run(() => CreateEventTopics(configuration, queueManager, logger))
                };
            Task.WaitAll(queueCreationTasks);
            logger.Debug("Queues and topics are all created.");

            logger.Debug("Creating message pumps and subscriptions.");
            var messagePumpCreationTasks =
                new[]
                {
                    Task.Run(() => CreateResponseMessagePump(configuration, messagingFactory, replyQueueName, requestResponseCorrelator, messagePumps, logger)),
                    Task.Run(() => CreateCommandMessagePumps(configuration, messagingFactory, messagePumps, logger)),
                    Task.Run(() => CreateRequestMessagePumps(configuration, messagingFactory, messagePumps, logger)),
                    Task.Run(() => CreateMulticastRequestMessagePumps(configuration, queueManager, messagingFactory, messagePumps, logger)),
                    Task.Run(() => CreateMulticastEventMessagePumps(configuration, queueManager, messagingFactory, messagePumps, logger)),
                    Task.Run(() => CreateCompetingEventMessagePumps(configuration, queueManager, messagingFactory, messagePumps, logger))
                };
            messagePumpCreationTasks.WaitAll();
            logger.Debug("Message pumps and subscriptions are all created.");

            var commandDeadLetterQueue = new DeadLetterQueue(queueManager);
            var requestDeadLetterQueue = new DeadLetterQueue(queueManager);
            var deadLetterQueues = new DeadLetterQueues(commandDeadLetterQueue, requestDeadLetterQueue);

            var bus = new Bus(commandSender, requestSender, multicastRequestSender, eventSender, messagePumps, deadLetterQueues);

            logger.Debug("Bus built. Job done!");

            return bus;
        }
コード例 #39
0
ファイル: BusBuilder.cs プロジェクト: nblumhardt/Nimbus
 private static void CreateMulticastRequestTopics(BusBuilderConfiguration configuration, QueueManager queueManager)
 {
     configuration.RequestTypes
                  .AsParallel()
                  .Do(queueManager.EnsureTopicExists)
                  .Done();
 }
コード例 #40
0
 public static BusBuilderConfiguration WithTypesFrom(this BusBuilderConfiguration configuration, ITypeProvider typeProvider)
 {
     configuration.TypeProvider = typeProvider;
     return(configuration);
 }
コード例 #41
0
 public static BusBuilderConfiguration WithEnableDeadLetteringOnMessageExpiration(this BusBuilderConfiguration configuration, bool enableDeadLettering)
 {
     configuration.EnableDeadLetteringOnMessageExpiration = new EnableDeadLetteringOnMessageExpirationSetting {
         Value = enableDeadLettering
     };
     return(configuration);
 }
コード例 #42
0
 public static BusBuilderConfiguration WithRouter(this BusBuilderConfiguration configuration, IRouter router)
 {
     configuration.Router = router;
     return(configuration);
 }
コード例 #43
0
ファイル: BusBuilder.cs プロジェクト: nblumhardt/Nimbus
        private static void CreateMulticastRequestMessagePumps(BusBuilderConfiguration configuration,
                                                               QueueManager queueManager,
                                                               MessagingFactory messagingFactory,
                                                               List<IMessagePump> messagePumps)
        {
            var requestTypes = configuration.RequestHandlerTypes.SelectMany(ht => ht.GetGenericInterfacesClosing(typeof (IHandleRequest<,>)))
                                            .Select(gi => gi.GetGenericArguments().First())
                                            .OrderBy(t => t.FullName)
                                            .Distinct()
                                            .ToArray();

            foreach (var requestType in requestTypes)
            {
                var applicationSharedSubscriptionName = String.Format("{0}", configuration.ApplicationName);
                queueManager.EnsureSubscriptionExists(requestType, applicationSharedSubscriptionName);

                var pump = new MulticastRequestMessagePump(messagingFactory,
                                                           configuration.MulticastRequestBroker,
                                                           requestType,
                                                           applicationSharedSubscriptionName,
                                                           configuration.Logger);
                messagePumps.Add(pump);
            }
        }
コード例 #44
0
ファイル: BusBuilder.cs プロジェクト: nhuhuynh/Nimbus
        private static void CreateEventTopics(BusBuilderConfiguration configuration, QueueManager queueManager, ILogger logger)
        {
            logger.Debug("Creating event topics");

            configuration.EventTypes
                         .AsParallel()
                         .Do(queueManager.EnsureTopicExists)
                         .Done();
        }
コード例 #45
0
 public static BusBuilderConfiguration WithLogger(this BusBuilderConfiguration configuration, ILogger logger)
 {
     configuration.Logger = logger;
     return(configuration);
 }
コード例 #46
0
 public static BusBuilderConfiguration WithLargeMessageStorage(this BusBuilderConfiguration configuration, Action <LargeMessageStorageConfiguration> configurationAction)
 {
     configurationAction(configuration.LargeMessageStorageConfiguration);
     return(configuration);
 }
コード例 #47
0
 /// <summary>
 ///     Log to the Serilog <see cref="Serilog.Log" /> class.
 /// </summary>
 /// <param name="configuration">The bus configuration to apply the logger to.</param>
 /// <returns>Bus configuration.</returns>
 public static BusBuilderConfiguration WithSerilogLogger(this BusBuilderConfiguration configuration)
 {
     return(configuration
            .WithLogger(new SerilogStaticLogger()));
 }