当前位置: 首页>>代码示例>>C#>>正文


C# BusConfiguration.DiscardFailedMessagesInsteadOfSendingToErrorQueue方法代码示例

本文整理汇总了C#中BusConfiguration.DiscardFailedMessagesInsteadOfSendingToErrorQueue方法的典型用法代码示例。如果您正苦于以下问题:C# BusConfiguration.DiscardFailedMessagesInsteadOfSendingToErrorQueue方法的具体用法?C# BusConfiguration.DiscardFailedMessagesInsteadOfSendingToErrorQueue怎么用?C# BusConfiguration.DiscardFailedMessagesInsteadOfSendingToErrorQueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BusConfiguration的用法示例。


在下文中一共展示了BusConfiguration.DiscardFailedMessagesInsteadOfSendingToErrorQueue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

        public void Start()
        {
            DynamicHostControllerConfig configSection = null;

            var o = new BusConfiguration();
            o.AssembliesToScan(GetType().Assembly);
            o.AzureConfigurationSource();
            o.RegisterComponents(Configurer =>
            {
                Configurer.ConfigureComponent<DynamicEndpointLoader>(DependencyLifecycle.SingleInstance);
                Configurer.ConfigureComponent<DynamicEndpointProvisioner>(DependencyLifecycle.SingleInstance);
                Configurer.ConfigureComponent<DynamicEndpointRunner>(DependencyLifecycle.SingleInstance);
                Configurer.ConfigureComponent<DynamicHostMonitor>(DependencyLifecycle.SingleInstance);

                configSection = o.GetSettings().GetConfigSection<DynamicHostControllerConfig>() ?? new DynamicHostControllerConfig();

                Configurer.ConfigureProperty<DynamicEndpointLoader>(t => t.ConnectionString, configSection.ConnectionString);
                Configurer.ConfigureProperty<DynamicEndpointLoader>(t => t.Container, configSection.Container);
                Configurer.ConfigureProperty<DynamicEndpointProvisioner>(t => t.LocalResource, configSection.LocalResource);
                Configurer.ConfigureProperty<DynamicEndpointProvisioner>(t => t.RecycleRoleOnError, configSection.RecycleRoleOnError);
                Configurer.ConfigureProperty<DynamicEndpointRunner>(t => t.RecycleRoleOnError, configSection.RecycleRoleOnError);
                Configurer.ConfigureProperty<DynamicEndpointRunner>(t => t.TimeToWaitUntilProcessIsKilled, configSection.TimeToWaitUntilProcessIsKilled);
                Configurer.ConfigureProperty<DynamicHostMonitor>(t => t.Interval, configSection.UpdateInterval);
            });

            o.UsePersistence<AzureStoragePersistence>();
            o.DiscardFailedMessagesInsteadOfSendingToErrorQueue();

            profileManager.ActivateProfileHandlers(o);
            specifier.Customize(o);

            var bus = (UnicastBus)Bus.CreateSendOnly(o);

            loader = bus.Builder.Build<DynamicEndpointLoader>();
            provisioner = bus.Builder.Build<DynamicEndpointProvisioner>();
            runner = bus.Builder.Build<DynamicEndpointRunner>();

            var endpointsToHost = loader.LoadEndpoints();
            if (endpointsToHost == null) return;

            runningServices = new List<EndpointToHost>(endpointsToHost);

            provisioner.Provision(runningServices);

            runner.Start(runningServices);

            if (!configSection.AutoUpdate) return;

            monitor = bus.Builder.Build<DynamicHostMonitor>();
            monitor.UpdatedEndpoints += UpdatedEndpoints;
            monitor.NewEndpoints += NewEndpoints;
            monitor.RemovedEndpoints += RemovedEndpoints;
            monitor.Monitor(runningServices);
            monitor.Start();
        }
开发者ID:mjhilton,项目名称:NServiceBus.Host.AzureCloudService,代码行数:55,代码来源:DynamicHostController.cs

示例2: Main

        static void Main(string[] args)
        {
            var testCaseToRun = args[0];

            int numberOfThreads;

            if (!int.TryParse(testCaseToRun, out numberOfThreads))
            {
                var testCase = TestCase.Load(testCaseToRun,args);

                testCase.Run();
                testCase.DumpSettings();
              
                return;
            }

            var volatileMode = (args[4].ToLower() == "volatile");
            var suppressDTC = (args[4].ToLower() == "suppressdtc");
            var twoPhaseCommit = (args[4].ToLower() == "twophasecommit");
            var saga = (args[5].ToLower() == "sagamessages");
            var encryption = (args[5].ToLower() == "encryption");
            var concurrency = int.Parse(args[7]);

            TransportConfigOverride.MaximumConcurrencyLevel = numberOfThreads;

            var numberOfMessages = int.Parse(args[1]);

            var endpointName = "PerformanceTest";

            if (volatileMode)
                endpointName += ".Volatile";

            if (suppressDTC)
                endpointName += ".SuppressDTC";

            var configuration = new BusConfiguration();

            configuration.EndpointName(endpointName);
            configuration.EnableInstallers();
            configuration.DiscardFailedMessagesInsteadOfSendingToErrorQueue();
            configuration.UseTransport<MsmqTransport>().ConnectionString("deadLetter=false;journal=false");
            configuration.DisableFeature<Audit>();

            if (volatileMode)
            {
                configuration.DisableDurableMessages();
                configuration.UsePersistence<InMemoryPersistence>();
            }

            switch (args[3].ToLower())
            {
                case "msmq":
                    configuration.UseTransport<MsmqTransport>();
                    break;

                default:
                    throw new InvalidOperationException("Illegal transport " + args[2]);
            }

            if (suppressDTC)
            {
                configuration.Transactions().DisableDistributedTransactions();
            }

            switch (args[2].ToLower())
            {
                case "xml":
                    configuration.UseSerialization<XmlSerializer>();
                    break;

                case "json":
                    configuration.UseSerialization<JsonSerializer>();
                    break;

                case "bson":
                    configuration.UseSerialization<BsonSerializer>();
                    break;

                case "bin":
                    configuration.UseSerialization<BinarySerializer>();
                    break;

                default:
                    throw new InvalidOperationException("Illegal serialization format " + args[2]);
            }
            configuration.UsePersistence<InMemoryPersistence>();
            configuration.RijndaelEncryptionService("KEY", Encoding.ASCII.GetBytes("gdDbqRpqdRbTs3mhdZh9qCaDaxJXl+e6"));
            

            using (var startableBus = Bus.Create(configuration))
            {
                if (saga)
                {
                    SeedSagaMessages(startableBus,numberOfMessages, endpointName, concurrency);
                }
                else
                {
                    Statistics.SendTimeNoTx = SeedInputQueue(startableBus,numberOfMessages / 2, endpointName, numberOfThreads, false, twoPhaseCommit, encryption);
                    Statistics.SendTimeWithTx = SeedInputQueue(startableBus,numberOfMessages / 2, endpointName, numberOfThreads, true, twoPhaseCommit, encryption);
                }
//.........这里部分代码省略.........
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:101,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            LogManager.Use<DefaultFactory>().Level(LogLevel.Fatal); //Comment out to see log messages
            BusConfiguration busConfiguration = new BusConfiguration();
            busConfiguration.EndpointName("nservicebus_test_client");
            busConfiguration.UseTransport<RabbitMQTransport>()
                .ConnectionString(ConfigurationManager.AppSettings["ServerConnectionString"]);
            busConfiguration.UseSerialization<JsonSerializer>();
            busConfiguration.UsePersistence<InMemoryPersistence>();
            busConfiguration.EnableInstallers();
            busConfiguration.DisableDurableMessages();
            busConfiguration.DiscardFailedMessagesInsteadOfSendingToErrorQueue();

            bool expectReply = Boolean.Parse(ConfigurationManager.AppSettings["ExpectReply"]);
            var taskCount = Int32.Parse(ConfigurationManager.AppSettings["NoOfThreads"]);
            var iterationsPerTask = Int32.Parse(ConfigurationManager.AppSettings["MessagesPerThread"]);

            IBus bus = Bus.Create(busConfiguration).Start();


            Task[] tasks = new Task[taskCount];
            for (int t = 0; t < taskCount; t++)
            {
                tasks[t] = new Task(() =>
                {
                    Message msg;
                    for (int i = 0; i < iterationsPerTask; i++)
                    {
                        msg = new Message { Body = BodyGenerator.GetNext() };

                        if (expectReply)
                        {
                            bus.Send("nservicebus_test_service", msg).Register((m) => { }).Wait();
                        }
                        else
                        {
                            bus.Send("nservicebus_test_service", msg);
                        }
                    }

                }, TaskCreationOptions.LongRunning);
            }

            Console.WriteLine("Sending " + iterationsPerTask * taskCount + " messages across " + taskCount + " threads");
            Stopwatch watch = new Stopwatch();
            watch.Start();
            for (int t = 0; t < taskCount; t++)
            {
                tasks[t].Start();
            }

            Task.WaitAll(tasks);

            watch.Stop();
            Console.WriteLine("Total time: " + watch.Elapsed);

            Console.ReadKey();
            bus.Dispose();


        }
开发者ID:tenor,项目名称:RestBus.Benchmarks,代码行数:61,代码来源:Program.cs

示例4: Main

        static void Main(string[] args)
        {
            var numberOfThreads = int.Parse(args[0]);
            var volatileMode = (args[4].ToLower() == "volatile");
            var suppressDTC = (args[4].ToLower() == "suppressdtc");
            var twoPhaseCommit = (args[4].ToLower() == "twophasecommit");
            var outbox = (args[4].ToLower() == "outbox");
            var saga = (args[5].ToLower() == "sagamessages");
            var publish = (args[5].ToLower() == "publishmessages");
            var concurrency = int.Parse(args[7]);

            TransportConfigOverride.MaximumConcurrencyLevel = numberOfThreads;

            var numberOfMessages = int.Parse(args[1]);

            var endpointName = "PerformanceTest";

            if (volatileMode)
            {
                endpointName += ".Volatile";
            }

            if (suppressDTC)
            {
                endpointName += ".SuppressDTC";
            }

            if (outbox)
            {
                endpointName += ".outbox";
            }

            var config = new BusConfiguration();
            config.EndpointName(endpointName);
            config.UseTransport<MsmqTransport>();
            config.EnableInstallers();

            switch (args[2].ToLower())
            {
                case "xml":
                    config.UseSerialization<XmlSerializer>();
                    break;

                case "json":
                    config.UseSerialization<JsonSerializer>();
                    break;

                case "bson":
                    config.UseSerialization<BsonSerializer>();
                    break;

                case "bin":
                    config.UseSerialization<BinarySerializer>();
                    break;

                default:
                    throw new InvalidOperationException("Illegal serialization format " + args[2]);
            }

            config.DisableFeature<Audit>();

            NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
                {
                    new ConnectionStringSettings("NServiceBus/Persistence", SqlServerConnectionString)
                };


            config.UsePersistence<NHibernatePersistence>();

            if (suppressDTC)
            {
                config.Transactions().DisableDistributedTransactions();
            }

            if (outbox)
            {
                config.EnableOutbox();
            }

            config.DiscardFailedMessagesInsteadOfSendingToErrorQueue();

            using (var startableBus = Bus.Create(config))
            {
                if (saga)
                {
                    SeedSagaMessages(startableBus,numberOfMessages, endpointName, concurrency);
                }
                else if (publish)
                {
                    Statistics.PublishTimeNoTx = PublishEvents(startableBus,numberOfMessages / 2, numberOfThreads, false);
                    Statistics.PublishTimeWithTx = PublishEvents(startableBus,numberOfMessages / 2, numberOfThreads, !outbox);
                }
                else
                {
                    Statistics.SendTimeNoTx = SeedInputQueue(startableBus,numberOfMessages / 2, endpointName, numberOfThreads, false, twoPhaseCommit);
                    Statistics.SendTimeWithTx = SeedInputQueue(startableBus,numberOfMessages / 2, endpointName, numberOfThreads, !outbox, twoPhaseCommit);
                }

                Statistics.StartTime = DateTime.Now;

//.........这里部分代码省略.........
开发者ID:james-wu,项目名称:NServiceBus.NHibernate,代码行数:101,代码来源:Program.cs


注:本文中的BusConfiguration.DiscardFailedMessagesInsteadOfSendingToErrorQueue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。