public void ScanningUpgrade()
        {
            BusConfiguration busConfiguration = new BusConfiguration();

            #region 5to6ScanningUpgrade

            IExcludesBuilder excludesBuilder =
                AllAssemblies.Matching("NServiceBus")
                .And("MyCompany.")
                .Except("BadAssembly1.dll")
                .And("BadAssembly2.dll");
            busConfiguration.AssembliesToScan(excludesBuilder);

            #endregion
        }
Ejemplo n.º 2
0
        void CustomConfigOverrides()
        {
            #region 4to5CustomConfigOverrides

            var configure = Configure.With(AllAssemblies.Except("NotThis.dll"));
            configure.DefaultBuilder();
            configure.DefineEndpointName("MyEndpointName");
            configure.DefiningEventsAs(
                type =>
            {
                return(type.Name.EndsWith("Event"));
            });

            #endregion
        }
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Component.For <ISendOnlyBus>().UsingFactoryMethod((kernel, componentModel) =>
            {
                var configuration = new BusConfiguration();
                configuration.EndpointName("CleanAir.UI");
                configuration.EnableInstallers();
                configuration.Transactions().DisableDistributedTransactions();
                configuration.UseSerialization <NServiceBus.JsonSerializer>();

                configuration.UseTransport <RabbitMQTransport>();
                configuration.UsePersistence <InMemoryPersistence>();
                configuration.AssembliesToScan(AllAssemblies.Except("ClearScript"));
                return(Bus.CreateSendOnly(configuration));
            }));
        }
Ejemplo n.º 4
0
    static IBus StartInstance1()
    {
        #region multi-hosting-assembly-scan

        BusConfiguration busConfiguration = new BusConfiguration();

        busConfiguration.EndpointName("Samples.MultiHosting.Instance1");
        busConfiguration.AssembliesToScan(AllAssemblies.Matching("Instance1.").And("Shared"));
        busConfiguration.UseSerialization <JsonSerializer>();
        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence <InMemoryPersistence>();

        return(Bus.Create(busConfiguration).Start());

        #endregion
    }
Ejemplo n.º 5
0
    static IBus StartInstance1()
    {
        #region multi-hosting-assembly-scan

        var busConfiguration = new BusConfiguration();

        busConfiguration.EndpointName("Samples.MultiHosting.Instance1");
        // only include Instance1.dll and dependent assemblies
        busConfiguration.AssembliesToScan(AllAssemblies.Matching("Instance1.").And("Shared"));
        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence <InMemoryPersistence>();

        return(Bus.Create(busConfiguration).Start());

        #endregion
    }
        void ScanningExcludeTypes(BusConfiguration busConfiguration)
        {
            #region ScanningExcludeTypes

            var allTypes = from a in AllAssemblies.Except("Dummy")
                           from t in a.GetTypes()
                           select t;

            var allowedTypesToScan = allTypes
                                     .Where(t => t != typeof(GenericHandler))
                                     .ToList();

            busConfiguration.TypesToScan(allowedTypesToScan);

            #endregion
        }
Ejemplo n.º 7
0
        public static BusConfiguration CreateAzureBusConfiguration(string azureSBConnection, bool useOutbox, bool disableTx)
        {
            if (disableTx && useOutbox)
            {
                throw new ArgumentException("Cannot use Outbox when transactions are disabled");
            }

            BusConfiguration busConfiguration = CreateAmbientTxConfiguration();

            if (useOutbox)
            {
                busConfiguration.EnableOutbox();
                Console.WriteLine("Default Configuration overridden: Using Outbox");
            }

            if (disableTx)
            {
                // A validation error will occur if NServiceBus detects SQL Transport, even if it not being used.
                // Explicitly remove NServiceBus SQL Transport from the assembly scanning
                busConfiguration.Transactions().DisableDistributedTransactions();
                IExcludesBuilder excludesBuilder = AllAssemblies
                                                   .Except("NServiceBus.Transports.SQLServer.dll");
                busConfiguration.AssembliesToScan(excludesBuilder);

                // Using different databases only work when transaction are disabled
                ConfigureHibernate(busConfiguration, DB_SHARED_CONNECTION);

                Console.WriteLine("Default Configuration overridden: Using Transport transaction only");
            }
            else
            {
                ConfigureHibernate(busConfiguration, DB_BUSINESS_CONNECTION);

                busConfiguration.Transactions().Enable().EnableDistributedTransactions();

                Console.WriteLine("Default Configuration: Using Ambient Transactions");
            }

            busConfiguration.UseTransport <AzureServiceBusTransport>()
            .ConnectionString(azureSBConnection);

            Console.WriteLine("Default Configuration overridden: Using Azure Tranport");

            return(busConfiguration);
        }
Ejemplo n.º 8
0
        public ScanningPublicApiV4()
        {
            IEnumerable <Assembly> myListOfAssemblies = null;

            Assembly assembly2 = null;
            Assembly assembly1 = null;

            IEnumerable <Type> myTypes = null;

            #region ScanningDefaultV4
            Configure.With();
            #endregion


            #region ScanningListOfAssembliesV4
            Configure.With(myListOfAssemblies);
            #endregion

            #region ScanningParamArrayOfAssembliesV4
            Configure.With(assembly1, assembly2);
            #endregion


            #region ScanningCustomDirectoryV4
            Configure.With(@"c:\my-custom-dir");
            #endregion


            #region ScanningListOfTypesV4
            Configure.With(myTypes);
            #endregion

            #region ScanningExcludeByNameV4
            Configure.With(AllAssemblies.Except("MyAssembly.dll").And("MyAssembly.dll"));
            #endregion

            #region ScanningIncludeByPatternV4
            Configure.With(AllAssemblies.Matching("MyCompany.").And("SomethingElse"));
            #endregion


            #region ScanningMixingIncludeAndExcludeV4
            Configure.With(AllAssemblies.Matching("MyCompany.").Except("BadAssembly.dll"));
            #endregion
        }
Ejemplo n.º 9
0
        private IBus ConfigureNServiceBus()
        {
            var configuration = new BusConfiguration();

            configuration.AssembliesToScan(AllAssemblies.Except("MediaLoanLIbrary.Fines.Common"));
            configuration.EndpointName("IntegrationTesting");
            configuration.DisableFeature <Sagas>();
            configuration.DisableFeature <TimeoutManager>();
            configuration.DisableFeature <AutoSubscribe>();
            configuration.DisableFeature <InMemorySubscriptionPersistence>();
            configuration.DisableFeature <StorageDrivenPublishing>();
            configuration.UsePersistence <InMemoryPersistence>();
            configuration.PurgeOnStartup(true);
            configuration.Conventions()
            .DefiningCommandsAs(type => UnobtrusiveMessageConventions.CommandsDefinition(type) || (UnobtrusiveMessageConventions.EventsDefinition(type) && type.Namespace.Contains(".Loans.")))
            .DefiningEventsAs(type => UnobtrusiveMessageConventions.EventsDefinition(type) && !type.Namespace.Contains(".Loans."));
            configuration.EnableInstallers();
            return(Bus.Create(configuration).Start());
        }
Ejemplo n.º 10
0
        public ScanningPublicApiV5()
        {
            var configuration = new BusConfiguration();
            IEnumerable <Assembly> myListOfAssemblies = null;

            Assembly assembly2 = null;
            Assembly assembly1 = null;

            IEnumerable <Type> myTypes = null;


            #region ScanningListOfAssembliesV5
            configuration.AssembliesToScan(myListOfAssemblies);
            #endregion

            #region ScanningParamArrayOfAssembliesV5
            configuration.AssembliesToScan(assembly1, assembly2);
            #endregion


            #region ScanningCustomDirectoryV5
            configuration.ScanAssembliesInDirectory(@"c:\my-custom-dir");
            #endregion


            #region ScanningListOfTypesV5
            configuration.TypesToScan(myTypes);
            #endregion

            #region ScanningExcludeByNameV5
            configuration.AssembliesToScan(AllAssemblies.Except("MyAssembly.dll").And("MyAssembly.dll"));
            #endregion

            #region ScanningIncludeByPatternV5
            configuration.AssembliesToScan(AllAssemblies.Matching("MyCompany.").And("SomethingElse"));
            #endregion


            #region ScanningMixingIncludeAndExcludeV5
            configuration.AssembliesToScan(AllAssemblies.Matching("MyCompany.").Except("BadAssembly.dll"));
            #endregion
        }
Ejemplo n.º 11
0
        public static IBus Setup(ILifetimeScope container)
        {
            LogManager.Use <DefaultFactory>();

            var configuration = new BusConfiguration();

            configuration.EndpointName("APIComparer.Website");
            configuration.UseContainer <AutofacBuilder>(x => x.ExistingLifetimeScope(container));
            configuration.AssembliesToScan(AllAssemblies.Except("Microsoft.Windows.Azure.Storage"));

            configuration.UseTransport <AzureStorageQueueTransport>()
            .ConnectionString(AzureEnvironment.GetConnectionString);
            configuration.UsePersistence <AzureStoragePersistence>();
            configuration.DisableFeature <SecondLevelRetries>();
            configuration.DisableFeature <Sagas>();
            configuration.DisableFeature <TimeoutManager>();
            configuration.EnableInstallers();

            return(Bus.Create(configuration).Start());
        }
Ejemplo n.º 12
0
        public void Start()
        {
            var assemblies = AllAssemblies.Except("IKVM.OpenJDK.Core.dll");

            var config = new BusConfiguration();

            config.UsePersistence <InMemoryPersistence>();
            config.Conventions().DefiningMessagesAs(x => (x.Namespace != null && x.Namespace.Contains("Contracts")));
            config.EndpointName(ConfigurationManager.AppSettings["EndpointName"]);
            config.EnableDurableMessages();
            config.UseSerialization <XmlSerializer>();
            config.UseTransport <RabbitMQTransport>().DisableCallbackReceiver();
            config.UseContainer <StructureMapBuilder>(c => c.ExistingContainer(StructureMapBuilderConfig.GetStructureMapContainer()));
            config.DisableFeature <SecondLevelRetries>();
            config.DisableFeature <StorageDrivenPublishing>();
            config.DisableFeature <TimeoutManager>();
            config.AssembliesToScan(assemblies);
            var buz = Bus.Create(config);

            buz.Start();
        }
        static void GetAllAssemblies(Assembly start)
        {
            AllAssemblies.Add(start.FullName, start);
            foreach (var item in start.GetReferencedAssemblies())
            {
                try
                {
                    if (AllAssemblies.ContainsKey(item.FullName))
                    {
                        continue;
                    }

                    var ass = Assembly.Load(item);
                    GetAllAssemblies(ass);
                }
                catch (Exception)
                {
                    //TODO:log
                }
            }
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var configuration = new BusConfiguration();

            configuration.EndpointName("web");
            configuration.UseTransport <MsmqTransport>();
            configuration.UseSerialization <JsonSerializer>();
            configuration.UsePersistence <InMemoryPersistence>();
            configuration.AssembliesToScan(AllAssemblies.Except("Razor"));
            configuration
            .Conventions()
            .DefiningCommandsAs(type => FilterByName(type, "Command"))
            .DefiningEventsAs(type => FilterByName(type, "Event"));

            Bus = NServiceBus.Bus.CreateSendOnly(configuration);
        }
Ejemplo n.º 15
0
        public static Configure SetupEndpoint()
        {
            Configure.Endpoint.AsSendOnly();
            Configure.Transactions.Disable();

            Configure.Features.Disable <NServiceBus.Features.AutoSubscribe>();
            Configure.Features.Disable <NServiceBus.Features.SecondLevelRetries>();
            Configure.Features.Disable <NServiceBus.Features.TimeoutManager>();
            Configure.Features.Disable <NServiceBus.Features.Gateway>();
            Configure.Features.Disable <NServiceBus.Features.Sagas>();

            Configure.Serialization.Xml();

            return(Configure.With(AllAssemblies.Matching("Messages.dll"))
                   .DefineEndpointName(ENDPOINT_NAME)
                   .DefiningCommandsAs(t => t.Namespace != null &&
                                       t.Namespace.Contains("Messages.") &&
                                       !t.Namespace.StartsWith("NServiceBus"))
                   .StructureMapBuilder(ObjectFactory.Container)
                   .UseTransport <Msmq>()
                   .UnicastBus());
        }
Ejemplo n.º 16
0
        static AssemblyHelper()
        {
            string rootPath   = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            var    assemblies = Directory.GetFiles(rootPath, "*.dll")
                                .Where(x => !new FileInfo(x).Name.StartsWith("System.") &&
                                       !new FileInfo(x).Name.StartsWith("Microsoft."))
                                .Select(x => Assembly.LoadFrom(x))
                                .Where(x => !x.IsDynamic)
                                .ToList();

            assemblies.ForEach(aAssembly =>
            {
                try
                {
                    AllTypes.AddRange(aAssembly.GetTypes());
                    AllAssemblies.Add(aAssembly);
                }
                catch
                {
                }
            });
        }
Ejemplo n.º 17
0
        private void PublisherFormShown(object sender, EventArgs e)
        {
            try
            {
                buttonPublishMessage.Enabled = false;
                Refresh();
                Thread.Sleep(1000);
                labelStatus.ForeColor = Color.Olive;
                labelStatus.Text      = "Preparing publisher...";
                Refresh();

                Thread.Sleep(1000);

                // Sets up the Bus to receive messages from publisher endpoints. See config file section
                Configure.Transactions.Enable();
                Bus = Configure
                      .With(AllAssemblies.Matching("AscEsbTrainingMessages"))
                      .DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("AscEsbTrainingMessages"))
                      .Log4Net()
                      .DefaultBuilder()
                      //.IsTransactional(true)
                      .DisableTimeoutManager()   // Stops default creation of RavenDB database.
                      .UseTransport <Msmq>()
                      .MsmqSubscriptionStorage()
                      .UnicastBus()
                      .CreateBus()
                      .Start(() => Configure.Instance.ForInstallationOn <NServiceBus.Installation.Environments.Windows>().Install());


                labelStatus.ForeColor        = Color.Green;
                labelStatus.Text             = "Ready to publish messages.";
                buttonPublishMessage.Enabled = true;
            }
            catch (Exception ex)
            {
                // Show contents of exception on the GUI
                labelStatus.Text = String.Format(ex.ToString());
            }
        }
Ejemplo n.º 18
0
        public Bootstrapper(ServiceBase host = null, HostArguments hostArguments = null)
        {
            Settings.ServiceName = DetermineServiceName(host, hostArguments);
            ConfigureLogging();
            var containerBuilder = new ContainerBuilder();

            Container = containerBuilder.Build();

            // Disable Auditing for the service control endpoint
            Configure.Features.Disable <Audit>();
            Configure.Features.Enable <Sagas>();
            Feature.Disable <AutoSubscribe>();
            Feature.Disable <SecondLevelRetries>();

            Configure.Serialization.Json();
            Configure.Transactions.Advanced(t => t.DisableDistributedTransactions());

            Feature.EnableByDefault <StorageDrivenPublisher>();
            Configure.ScaleOut(s => s.UseSingleBrokerQueue());

            var transportType = DetermineTransportType();

            bus = Configure
                  .With(AllAssemblies.Except("ServiceControl.Plugin"))
                  .DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t) || IsExternalContract(t))
                  .DefineEndpointName(Settings.ServiceName)
                  .AutofacBuilder(Container)
                  .UseTransport(transportType)
                  .MessageForwardingInCaseOfFault()
                  .DefineCriticalErrorAction((s, exception) =>
            {
                if (host != null)
                {
                    host.Stop();
                }
            })
                  .UnicastBus()
                  .CreateBus();
        }
Ejemplo n.º 19
0
    static void Main()
    {
        BusConfiguration busConfiguration = new BusConfiguration();

        busConfiguration.EndpointName("Samples.ProgressBar.Endpoint");
        busConfiguration.UseSerialization <JsonSerializer>();
        busConfiguration.UsePersistence <InMemoryPersistence>();
        busConfiguration.EnableInstallers();
        busConfiguration.RegisterComponents(c => c.ConfigureComponent <StatusStoreClient>(DependencyLifecycle.InstancePerCall));

        var excludesBuilder =
            AllAssemblies
            .Except("System.*");

        busConfiguration.AssembliesToScan(excludesBuilder);

        using (IBus bus = Bus.Create(busConfiguration).Start())
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }
Ejemplo n.º 20
0
        public void Customize(BusConfiguration configuration)
        {
            configuration.UseTransport <MsmqTransport>();
            configuration.UsePersistence <InMemoryPersistence>();

            configuration.AssembliesToScan(AllAssemblies.Except("ABCpdf9-32.dll"));
            configuration.UseSerialization <JsonSerializer>();
            configuration.EndpointName("testqueue");

            configuration.DisableFeature <AutoSubscribe>();
            configuration.DisableFeature <SecondLevelRetries>();

            var conventionsBuilder = configuration.Conventions();

            conventionsBuilder.DefiningCommandsAs(t => t.Namespace != null &&
                                                  !t.IsInterface &&
                                                  t.Name.EndsWith("Command"));
            conventionsBuilder.DefiningMessagesAs(t => t.Namespace != null &&
                                                  !t.IsInterface &&
                                                  t.Name.EndsWith("Notification"));

            Bus.Create(configuration);
        }
        public void Customize(BusConfiguration config)
        {
            log4net.Config.XmlConfigurator.Configure();
            NServiceBus.Logging.LogManager.Use <Log4NetFactory>();


            var conventions = config.Conventions();

            conventions
            .DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("Demo") && t.Namespace.EndsWith("Events"))
            .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Demo") && t.Namespace.EndsWith("Commands"))
            .DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("Demo") && (t.Namespace.EndsWith("Messages") || t.Namespace.EndsWith("Queries")));

            config.LicensePath(@"C:\License.xml");

            config.EndpointName("DemoMessages");
            config.EndpointVersion("0.0.0");
            config.AssembliesToScan(AllAssemblies.Matching("DemoMessages").And("Domain"));

            config.UsePersistence <InMemoryPersistence>();
            config.UseContainer <StructureMapBuilder>(c => c.ExistingContainer(_container));
            config.UseSerialization <NServiceBus.JsonSerializer>();
        }
        private static void ProcessAssembly(AllAssemblies allAssemblies, FileSystemPath productBinariesDir,
                                            MetadataLoader metadataLoader, AssemblyNameInfo assemblyNameInfo,
                                            HashSet <ApplicationPackageFile> packageFiles, HashSet <ApplicationPackageReference> packageReferences)
        {
            var assembly = metadataLoader.TryLoad(assemblyNameInfo, JetFunc <AssemblyNameInfo> .False, false);

            if (assembly == null)
            {
                return;
            }

            var subplatformOfAssembly = allAssemblies.FindSubplatformOfAssembly(assemblyNameInfo, OnError.Ignore);

            if (subplatformOfAssembly != null)
            {
                var subplatformReference = new ApplicationPackageReference(subplatformOfAssembly.Name,
                                                                           subplatformOfAssembly.GetCompanyNameHuman());
                packageReferences.Add(subplatformReference);
                return;
            }

            if (assembly.AssemblyName?.Name.Contains("Microsoft.CodeAnalysis") == true)
            {
                return;
            }
            if (!packageFiles.Add(new ApplicationPackageFile(assembly.Location.MakeRelativeTo(productBinariesDir),
                                                             assemblyNameInfo)))
            {
                return;
            }

            foreach (var referencedAssembly in assembly.ReferencedAssembliesNames)
            {
                ProcessAssembly(allAssemblies, productBinariesDir, metadataLoader, referencedAssembly, packageFiles,
                                packageReferences);
            }
        }
Ejemplo n.º 23
0
        public override ServiceStackHost Init()
        {
            ServicePointManager.UseNagleAlgorithm      = false;
            ServicePointManager.DefaultConnectionLimit = 1000;

            var conf = NLog.Config.ConfigurationItemFactory.Default;

            conf.LayoutRenderers.RegisterDefinition("logsdir", typeof(LogsDir));
            conf.LayoutRenderers.RegisterDefinition("Domain", typeof(Library.Logging.Domain));
            NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration($"{AppDomain.CurrentDomain.BaseDirectory}/logging.config");

            LogManager.LogFactory = new global::ServiceStack.Logging.NLogger.NLogFactory();
            AppDomain.CurrentDomain.UnhandledException   += UnhandledExceptionTrapper;
            AppDomain.CurrentDomain.FirstChanceException += ExceptionTrapper;
            NServiceBus.Logging.LogManager.Use <NServiceBus.NLogFactory>();


            IRedisClientsManager redisClient = null;
            ICacheClient         cacheClient;
            IServerEvents        serverEvents;
            var connectionString = ConfigurationManager.ConnectionStrings["Redis"];

            if (connectionString == null)
            {
                cacheClient  = new MemoryCacheClient();
                serverEvents = new MemoryServerEvents
                {
                    IdleTimeout = TimeSpan.FromSeconds(30),
                    NotifyChannelOfSubscriptions = false
                };
            }
            else
            {
                redisClient  = new BasicRedisClientManager(connectionString.ConnectionString);
                cacheClient  = new RedisClientManagerCacheClient(redisClient);
                serverEvents = new RedisServerEvents(redisClient)
                {
                    Timeout = TimeSpan.FromSeconds(30),
                    NotifyChannelOfSubscriptions = false,
                };
            }

            IDbConnectionFactory sql = null;
            var connectionStringSQL  = ConfigurationManager.ConnectionStrings["SQL"];

            if (connectionStringSQL != null)
            {
                sql = new OrmLiteConnectionFactory(connectionStringSQL.ConnectionString, SqlServer2012Dialect.Provider)
                {
                    ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                };
            }



            _container = new Container(x =>
            {
                if (redisClient != null)
                {
                    x.For <IRedisClientsManager>().Use(redisClient);
                }
                if (sql != null)
                {
                    x.For <IDbConnectionFactory>().Use(sql);
                    x.For <ISubscriptionStorage>().Use <MSSQLStorage>();
                }
                else
                {
                    x.For <ISubscriptionStorage>().Use <MemoryStorage>();
                }

                x.For <IManager>().Use <Manager>();
                x.For <IFuture>().Use <Future>().Singleton();
                x.For <ICacheClient>().Use(cacheClient);
                x.For <IServerEvents>().Use(serverEvents);
                x.For <ISubscriptionManager>().Use <SubscriptionManager>().Singleton();

                x.Scan(y =>
                {
                    AllAssemblies.Matching("Presentation.ServiceStack").ToList().ForEach(a => y.Assembly(a));

                    y.WithDefaultConventions();
                    y.AddAllTypesOf <ISetup>();
                });
            });

            // Do this before bus starts
            InitiateSetup();
            SetupApplication();

            var config = new BusConfiguration();

            Logger.Info("Initializing Service Bus");
            config.LicensePath(ConfigurationManager.AppSettings["license"]);

            var endpoint = ConfigurationManager.AppSettings["endpoint"];

            if (string.IsNullOrEmpty(endpoint))
            {
                endpoint = "application.servicestack";
            }

            config.EndpointName(endpoint);

            config.EnableInstallers();
            config.UsePersistence <InMemoryPersistence>();
            config.UseContainer <StructureMapBuilder>(c => c.ExistingContainer(_container));

            config.DisableFeature <Sagas>();
            config.DisableFeature <SecondLevelRetries>();
            // Important to not subscribe to messages as we receive them from the event store
            config.DisableFeature <AutoSubscribe>();

            config.UseTransport <RabbitMQTransport>()
            .CallbackReceiverMaxConcurrency(36)
            .UseDirectRoutingTopology()
            .ConnectionStringName("RabbitMq");

            config.Transactions().DisableDistributedTransactions();
            //config.DisableDurableMessages();

            config.UseSerialization <NewtonsoftSerializer>();

            config.EnableFeature <Aggregates.Feature>();



            if (Logger.IsDebugEnabled)
            {
                config.Pipeline.Register <LogIncomingRegistration>();
            }

            var bus = Bus.Create(config).Start();

            _container.Configure(x => x.For <IBus>().Use(bus).Singleton());

            return(base.Init());
        }
Ejemplo n.º 24
0
        private static void Main(string[] args)
        {
            ServicePointManager.UseNagleAlgorithm = false;
            var conf = NLog.Config.ConfigurationItemFactory.Default;

            conf.LayoutRenderers.RegisterDefinition("logsdir", typeof(LogsDir));
            conf.LayoutRenderers.RegisterDefinition("Domain", typeof(Library.Logging.Domain));
            NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration($"{AppDomain.CurrentDomain.BaseDirectory}/logging.config");

            AppDomain.CurrentDomain.UnhandledException   += UnhandledExceptionTrapper;
            AppDomain.CurrentDomain.FirstChanceException += ExceptionTrapper;

            NServiceBus.Logging.LogManager.Use <NLogFactory>();
            //EventStore.Common.Log.LogManager.SetLogFactory((name) => new EmbeddedLogger(name));

            var embedded = args.FirstOrDefault(x => x.StartsWith("--embedded"));

            try
            {
                _embedded = Boolean.Parse(embedded.Substring(embedded.IndexOf('=') + 1));
            }
            catch { }

            var client = ConfigureStore();

            var riak = ConfigureRiak();

            ConfigureMetrics();

            _container = new Container(x =>
            {
                x.For <IManager>().Use <Manager>();
                x.For <IEventStoreConnection>().Use(client).Singleton();
                x.For <IEventMutator>().Use <EventMutator>();
                x.For <IFuture>().Use <Future>().Singleton();
                x.For <Infrastructure.IUnitOfWork>().Use <UnitOfWork>();
                x.For <ICommandUnitOfWork>().Add(b => (ICommandUnitOfWork)b.GetInstance <Infrastructure.IUnitOfWork>());
                x.For <IEventUnitOfWork>().Add(b => (IEventUnitOfWork)b.GetInstance <Infrastructure.IUnitOfWork>());
                x.For <IRiakClient>().Use(riak).Singleton();

                x.Scan(y =>
                {
                    AllAssemblies.Matching("Domain").ToList().ForEach(a => y.Assembly(a));

                    y.WithDefaultConventions();
                });
            });
            // Do this before bus starts
            InitiateSetup();
            SetupApplication();

            var bus = InitBus();

            _container.Configure(x => x.For <IBus>().Use(bus).Singleton());

            Console.WriteLine("Press CTRL+C to exit...");
            Console.CancelKeyPress += (sender, eArgs) =>
            {
                _quitEvent.Set();
                eArgs.Cancel = true;
            };
            _quitEvent.WaitOne();
        }
 public void MustNotReferenceDllsFromTransientOrSdkDirectories()
 {
     AllAssemblies.WithNamesMatching("Conventional*")
     .MustConformTo(Convention.MustNotReferenceDllsFromTransientOrSdkDirectories)
     .WithFailureAssertion(Assert.Fail);
 }
Ejemplo n.º 26
0
 public void Init()
 {
     Configure.With(AllAssemblies.Except("NServiceBus.Hosting.Azure.HostProcess.exe"));
 }
Ejemplo n.º 27
0
 private AssemblyPointer FindAssemblyByName(AssemblyName name)
 {
     return(AllAssemblies.FirstOrDefault(x => x.GetName().FullName == name.FullName));
 }
Ejemplo n.º 28
0
        ////////////////////////////
        ///////PUBLIC GETTERS///////
        ////////////////////////////

        public AssemblyPointer FindPointerByName(string name)
        {
            return(AllAssemblies.FirstOrDefault(x => x.GetName().Name == name));
        }
Ejemplo n.º 29
0
 public void Init()
 {
     Configure.With(AllAssemblies.Except("FacebookEndpoint.vshost.exe"));
 }
Ejemplo n.º 30
0
 public AssemblyPointer FindPointerByPrettyName(string prettyName)
 {
     return(AllAssemblies.FirstOrDefault(x => x.PrettyName == prettyName));
 }