Пример #1
0
    StaticUsage(ServiceBusTriggeredEndpointConfiguration serviceBusTriggeredEndpointConfiguration, FunctionExecutionContext executionContext)
    {
        #region asb-enable-diagnostics

        serviceBusTriggeredEndpointConfiguration.LogDiagnostics();

        #endregion
    }
Пример #2
0
 public override void Configure(IFunctionsHostBuilder builder)
 {
     builder.UseNServiceBus(() => {
         var configuration = new ServiceBusTriggeredEndpointConfiguration("MyFunctionsEndpoint");
         configuration.LogDiagnostics();
         return(configuration);
     });
 }
Пример #3
0
        public static ServiceBusTriggeredEndpointConfiguration BuildEndpointConfiguration(IFunctionsHostBuilder builder, IConfiguration configuration)
        {
            var endpointConfiguration = new ServiceBusTriggeredEndpointConfiguration(configuration["NServiceBus:EndpointName"]);

            endpointConfiguration.LogDiagnostics();
            var e = endpointConfiguration.AdvancedConfiguration;

            var serialization = e.UseSerialization <NewtonsoftSerializer>();

            // Newtonsoft serializer doesn't properly deserialize properties with protected setter,
            // the following serializer settings will be applied by NServiceBus during all messages's deserializations
            serialization.Settings(EventSerialization.Settings);

            e.Conventions().DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith("Events"));

            e.AuditProcessedMessagesTo(configuration["NServiceBus:AuditQueue"]);
            e.SendFailedMessagesTo(configuration["NServiceBus:ErrorQueue"]);
            //e.SendHeartbeatTo(serviceControlQueue: configuration["NServiceBus:ServiceControlInstance"],
            //    frequency: TimeSpan.FromSeconds(15),
            //    timeToLive: TimeSpan.FromSeconds(30));

            //var endpointName = configuration["NServiceBus:EndpointName"];
            //var machineName = $"{Dns.GetHostName()}.{IPGlobalProperties.GetIPGlobalProperties().DomainName}";
            //var instanceIdentifier = $"{endpointName}@{machineName}";

            //var metrics = e.EnableMetrics();
            //metrics.SendMetricDataToServiceControl(serviceControlMetricsAddress: configuration["NServiceBus:ServiceControlMonitoringInstance"],
            //    interval: TimeSpan.FromSeconds(10),
            //    instanceId: instanceIdentifier);

            //This instruction checks every time the application starts up in order to create
            //all the necessary NServiceBus objects in the database automatically
            var settings = e.GetSettings();

            settings.Set("SqlPersistence.ScriptDirectory", builder.GetContext().ApplicationRootPath);
            e.EnableInstallers();

            return(endpointConfiguration);
        }
Пример #4
0
    public override void Configure(IFunctionsHostBuilder builder)
    {
        var services = builder.Services;

        // register custom service in the container
        services.AddSingleton(_ =>
        {
            var configurationRoot = builder.GetContext().Configuration;
            var customComponentInitializationValue = configurationRoot.GetValue <string>("CustomComponentValue");

            return(new CustomComponent(customComponentInitializationValue));
        });

        builder.UseNServiceBus(() =>
        {
            var configuration = new ServiceBusTriggeredEndpointConfiguration(Startup.EndpointName);

            // optional: log startup diagnostics using Functions provided logger
            configuration.LogDiagnostics();

            return(configuration);
        });
    }