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


C# EndpointConfiguration.DefineCriticalErrorAction方法代码示例

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


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

示例1: CriticalErrors

        CriticalErrors(EndpointConfiguration endpointConfiguration)
        {
            #region DefiningCustomHostErrorHandlingAction

            endpointConfiguration.DefineCriticalErrorAction(OnCriticalError);

            #endregion
        }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:8,代码来源:CriticalErrors.cs

示例2: CriticalErrors

        CriticalErrors()
        {
            #region DefiningCustomHostErrorHandlingAction

            EndpointConfiguration configuration = new EndpointConfiguration();
            configuration.DefineCriticalErrorAction(OnCriticalError);

            #endregion
        }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:9,代码来源:CriticalErrors.cs

示例3: CriticalError

 public void CriticalError()
 {
     // ReSharper disable RedundantDelegateCreation
     // ReSharper disable ConvertToLambdaExpression
     #region 5to6CriticalError
     EndpointConfiguration configuration = new EndpointConfiguration();
     configuration.DefineCriticalErrorAction(
         new Func<ICriticalErrorContext,Task>(context =>
         {
             // place you custom handling here 
             return Task.FromResult(0);
         }));
     #endregion
     // ReSharper restore RedundantDelegateCreation
     // ReSharper restore ConvertToLambdaExpression
 }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:16,代码来源:Upgrade.cs

示例4: CriticalErrorConfigAzure

        CriticalErrorConfigAzure(EndpointConfiguration endpointConfiguration, ILog log)
        {
            #region DefineCriticalErrorActionForAzureHost

            // Configuring how NServicebus handles critical errors
            endpointConfiguration.DefineCriticalErrorAction(context =>
            {
                string output = $"Critical exception: '{context.Error}'";
                log.Error(output, context.Exception);
                if (Environment.UserInteractive)
                {
                    Thread.Sleep(10000); // so that user can see on their screen the problem
                }

                string fatalMessage = $"The following critical error was encountered by NServiceBus:\n{context.Error}\nNServiceBus is shutting down.";
                Environment.FailFast(fatalMessage, context.Exception);
                return Task.FromResult(0);
            });

            #endregion
        }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:21,代码来源:CriticalErrorConfigAzure.cs

示例5: DefineCriticalErrorActionForAzureHost

        public void DefineCriticalErrorActionForAzureHost()
        {
            EndpointConfiguration endpointConfiguration = new EndpointConfiguration();

            #region DefineCriticalErrorActionForAzureHost

            // Configuring how NServicebus handles critical errors
            endpointConfiguration.DefineCriticalErrorAction(context =>
            {
                string errorMessage = $"We got a critical exception: '{context.Error}'\r\n{context.Exception}";

                if (Environment.UserInteractive)
                {
                    Thread.Sleep(10000); // so that user can see on their screen the problem
                }

                string fatalMessage = $"The following critical error was encountered by NServiceBus:\n{errorMessage}\nNServiceBus is shutting down.";
                Environment.FailFast(fatalMessage, context.Exception);
                return Task.FromResult(0);
            });

            #endregion
        }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:23,代码来源:CriticalError.cs

示例6: AsyncOnStart

    async Task AsyncOnStart()
    {
        #region logging

        PatternLayout layout = new PatternLayout
        {
            ConversionPattern = "%d %-5p %c - %m%n"
        };
        layout.ActivateOptions();
        ConsoleAppender appender = new ConsoleAppender
        {
            Layout = layout,
            Threshold = Level.Info
        };
        appender.ActivateOptions();

        BasicConfigurator.Configure(appender);

        LogManager.Use<Log4NetFactory>();

        #endregion

        #region create-config

        EndpointConfiguration endpointConfiguration = new EndpointConfiguration();

        #endregion

        #region endpoint-name

        endpointConfiguration.EndpointName("Samples.FirstEndpoint");

        #endregion

        #region container

        ContainerBuilder builder = new ContainerBuilder();
        //configure your custom services
        //builder.RegisterInstance(new MyService());
        IContainer container = builder.Build();
        endpointConfiguration.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(container));

        #endregion

        #region serialization

        endpointConfiguration.UseSerialization<JsonSerializer>();

        #endregion
        #region error
        endpointConfiguration.SendFailedMessagesTo("error");
        #endregion

        #region transport

        endpointConfiguration.UseTransport<MsmqTransport>();

        #endregion

        #region sagas 

        //Not required since Sagas are enabled by default in Version 5

        #endregion

        #region persistence

        endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Sagas>();
        endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Subscriptions>();
        endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();

        #endregion

        #region critical-errors
        endpointConfiguration.DefineCriticalErrorAction(async context =>
        {
            // Log the critical error
            logger.Fatal($"CRITICAL: {context.Error}", context.Exception);

            await context.Stop();

            // Kill the process on a critical error
            string output = $"The following critical error was encountered by NServiceBus:\n{context.Error}\nNServiceBus is shutting down.";
            Environment.FailFast(output, context.Exception);
        });

        #endregion

        #region start-bus

        endpointConfiguration.EnableInstallers();
        endpoint = await Endpoint.Start(endpointConfiguration);
        #endregion


        await endpoint.SendLocal(new MyMessage());
    }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:97,代码来源:ProgramService.cs


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