コード例 #1
0
ファイル: Service1.cs プロジェクト: mnowak82/nginn-messagebus
        protected override void OnStart(string[] args)
        {
            string           componentConfig = ConfigurationManager.AppSettings["NGinnMessageBus.ServiceHost.ComponentConfig"];
            bool             section         = ConfigurationManager.GetSection(componentConfig) != null;
            WindsorContainer wc = null;

            if (!string.IsNullOrEmpty(componentConfig))
            {
                if (section)
                {
                    wc = new WindsorContainer(new XmlInterpreter(new ConfigResource(componentConfig)));
                }
                else if (Path.GetExtension(componentConfig) == "xml" || Path.GetExtension(componentConfig) == ".xml")
                {
                    log.Info("Configuring the container from xml file: {0}", componentConfig);
                    wc = new WindsorContainer(new XmlInterpreter(new FileResource(componentConfig, AppDomain.CurrentDomain.BaseDirectory)));
                }
                else
                {
                    throw new Exception("Don't know how to load config: " + componentConfig);
                }
            }
            else
            {
                wc = new WindsorContainer();
            }
            _host = MessageBusConfigurator.Begin(wc)
                    .ConfigureFromAppConfig()
                    .AutoStartMessageBus(true)
                    .FinishConfiguration();
        }
コード例 #2
0
        public static IWindsorContainer ConfigureMessageBus(string endpointName, IDictionary <string, string> dbConnectionStrings)
        {
            MessageBusConfigurator cfg = MessageBusConfigurator.Begin()
                                         .SetEndpoint(endpointName)
                                         .SetConnectionStrings(dbConnectionStrings.Select((kv, i) => new ConnectionStringSettings {
                Name = kv.Key, ProviderName = "System.Data.SqlClient", ConnectionString = kv.Value
            }))
                                         .UseSqlSubscriptions()
                                         .UseStaticMessageRouting("Routing.json")
                                         //.RegisterHttpMessageServicesFromAssembly(typeof(Program).Assembly)
                                         .AddMessageHandlersFromAssembly(typeof(Setup).Assembly)
                                         .UseSqlSequenceManager()
                                         .SetEnableSagas(false)
                                         .SetSendOnly(false)
                                         .SetMaxConcurrentMessages(1)
                                         .SetUseTransactionScope(true)
                                         .SetAlwaysPublishLocal(false)
                                         .SetReuseReceiveConnectionForSending(true)
                                         .SetExposeReceiveConnectionToApplication(true)
                                         .SetDefaultSubscriptionLifetime(TimeSpan.FromHours(8))
                                         .AutoStartMessageBus(true);

            cfg.FinishConfiguration();
            return(cfg.Container);
        }
コード例 #3
0
 public static IWindsorContainer ConfigureTheBus()
 {
     return(MessageBusConfigurator.Begin()
            .ConfigureFromAppConfig()
            .AutoStartMessageBus(true)
            .FinishConfiguration()
            .Container);
 }
コード例 #4
0
 void Application_Start(object sender, EventArgs e)
 {
     this.mc = MessageBusConfigurator.Begin()
               .ConfigureFromAppConfig()
               .UseSqlSubscriptions()
               .FinishConfiguration()
               .StartMessageBus();
     MessageBus = mc.GetMessageBus();
 }
コード例 #5
0
 public static IWindsorContainer ConfigureTheBusSendOnly()
 {
     return(MessageBusConfigurator.Begin()
            .ConfigureFromAppConfig()
            .AutoStartMessageBus(true)
            .UseStaticMessageRouting("routing.json")
            .SetSendOnly(true)
            .FinishConfiguration()
            .Container);
 }
コード例 #6
0
        public static IMessageBus ConfigureMongoBus()
        {
            IMessageBus bus = MessageBusConfigurator.Begin()
                              .SetEndpoint("mongodb://localhost:27017/cogmon?queueName=Queue1")
                              .SetEnableSagas(true)
                              .SetMaxConcurrentMessages(8)
                              .SetReuseReceiveConnectionForSending(true)
                              .UseMongoDb()
                              .AddMessageHandlersFromAssembly(typeof(MongoQueue).Assembly)
                              .AutoStartMessageBus(true)
                              .FinishConfiguration()
                              .GetMessageBus();

            return(bus);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: mnowak82/nginn-messagebus
        public static IWindsorContainer Configure(string endpoint, bool sendOnly)
        {
            var mc = MessageBusConfigurator.Begin()
                     .ConfigureFromAppConfig()
                     .SetEndpoint(endpoint)
                     .SetSendOnly(sendOnly)
                     .AddMessageHandlersFromAssembly(typeof(Program).Assembly)
                     .AutoStartMessageBus(true)
                     .BatchOutgoingMessages(true
                                            )
                     //.UseExternalHandlerContainer(new WindsorServiceResolver(null))
                     .FinishConfiguration();

            return(mc.Container);
        }
コード例 #8
0
        public static IMessageBus ConfigureMessageBus()
        {
            var wc = MessageBusConfigurator.Begin()
                     .ConfigureFromAppConfig()
                     .UseStaticMessageRouting("route.json")
                     .AutoCreateDatabase(false)
                     .SetEnableSagas(false)
                     .SetAlwaysPublishLocal(true)
                     .AddMessageHandlersFromAssembly(typeof(OracleTests).Assembly)
                     .SetMaxConcurrentMessages(1)
                     .AutoStartMessageBus(true)
                     .FinishConfiguration()
                     .Container;

            return(wc.Resolve <IMessageBus>());
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: mnowak82/nginn-messagebus
        static void Main(string[] args)
        {
            NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging(LogLevel.Warn);
            var mc = MessageBusConfigurator.Begin()
                     .ConfigureFromAppConfig()
                     .AddMessageHandlersFromAssembly(typeof(Program).Assembly)
                     .FinishConfiguration()
                     .StartMessageBus();
            IMessageBus mb = mc.GetMessageBus();

            mb.SubscribeAt(System.Configuration.ConfigurationManager.AppSettings["PublisherEndpoint"], typeof(Object));
            Console.WriteLine("Subscriber at {0} ready to receive messages. Press Enter to exit", mb.Endpoint);
            Console.ReadLine();
            Console.WriteLine("Stopping...");
            mc.StopMessageBus();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: mnowak82/nginn-messagebus
        public static IWindsorContainer ConfigureMessageBus(string endpointName, IDictionary <string, string> dbConnectionStrings, string httpUrl)
        {
            MessageBusConfigurator cfg = MessageBusConfigurator.Begin()
                                         .SetEndpoint(endpointName)
                                         .SetConnectionStrings(dbConnectionStrings.Select((kv, i) => new ConnectionStringSettings {
                Name = kv.Key, ProviderName = "System.Data.SqlClient", ConnectionString = kv.Value
            }))
                                         .UseSqlSubscriptions()
                                         .UseStaticMessageRouting("Routing.json")
                                         //.RegisterHttpMessageServicesFromAssembly(typeof(Program).Assembly)
                                         .AddMessageHandlersFromAssembly(typeof(Program).Assembly)
                                         .UseSqlSequenceManager()
                                         .SetEnableSagas(true)
                                         .SetSendOnly(false)
                                         .SetMaxConcurrentMessages(4)
                                         .SetUseTransactionScope(true)
                                         .SetAlwaysPublishLocal(false)
                                         .SetReuseReceiveConnectionForSending(true)
                                         .SetExposeReceiveConnectionToApplication(true)
                                         .SetDefaultSubscriptionLifetime(TimeSpan.FromHours(8))
                                         .AutoStartMessageBus(true);

            if (httpUrl != null)
            {
                cfg.ConfigureHttpReceiver(httpUrl);
            }
            cfg.CustomizeContainer(delegate(IWindsorContainer wc)
            {
                /*wc.Register(Component.For<NGinnBPM.MessageBus.Impl.ISerializeMessages>()
                 *  .ImplementedBy<NGinnBPM.MessageBus.Impl.ServiceStackMessageSerializer>()
                 *  .DependsOn(new { UseFullAssemblyNames = false })
                 *  .LifeStyle.Singleton);*/
                wc.Register(Component.For <IServlet>()
                            .ImplementedBy <FSDirectoryServlet>()
                            .DependsOn(new
                {
                    MatchUrl      = @"/www/(?<id>.+)?",
                    BaseDirectory = "c:\\inetpub\\wwwroot"
                }).LifeStyle.Transient);
            });
            //cfg.ConfigureAdditionalSqlMessageBus("bus2", "sql://testdb1/MQueue2");
            cfg.FinishConfiguration();
            //cfg.StartMessageBus();

            return(cfg.Container);
        }
コード例 #11
0
        public NGinnConfigurator FinishConfiguration()
        {
            _wc.Register(Component.For <ProcessEngine>()
                         .ImplementedBy <ProcessEngine>()
                         .LifeStyle.Singleton);
            _wc.Register(Component.For <ITaskInstancePersister>()
                         .ImplementedBy <SqlProcessPersister>()
                         .LifeStyle.Singleton);
            _wc.Register(Component.For <ITaskInstanceSerializer>()
                         .ImplementedBy <JsonTaskInstanceSerializer>());

            MessageBusConfigurator.Begin(_wc)
            .AddMessageHandlersFromAssembly(typeof(TaskInstance).Assembly)
            .AddMessageHandlersFromAssembly(typeof(NGinnConfigurator).Assembly)
            .ConfigureFromAppConfig()
            .AutoStartMessageBus(true)
            .FinishConfiguration();
            return(this);
        }