Giter Club home page Giter Club logo

Comments (3)

bording avatar bording commented on July 18, 2024

@dnv-kimbell

It is already possible to use IHostApplicationLifetime methods from your critical error action. For example, here's one way you can do that:

var builder = Host.CreateApplicationBuilder(args);

IHostApplicationLifetime lifetime = null;

var endpointConfiguration = new EndpointConfiguration("example");
var routing = endpointConfiguration.UseTransport(new LearningTransport());
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
endpointConfiguration.DefineCriticalErrorAction((context, cancellationToken) => OnCriticalError(context, cancellationToken, lifetime));

builder.UseNServiceBus(endpointConfiguration);

var app = builder.Build();
lifetime = app.Services.GetRequiredService<IHostApplicationLifetime>();
app.Run();

static Task OnCriticalError(ICriticalErrorContext context, CancellationToken cancellationToken, IHostApplicationLifetime lifetime)
{
    lifetime.StopApplication();

    return Task.CompletedTask;
}

from nservicebus.

dnv-kimbell avatar dnv-kimbell commented on July 18, 2024

We have an application portfolio spanning 150 repos containing deployable code; mixture of ASP.NET and Windows Services. In order to keep this maintainable and consistent, we have created a highly opinionated framework on top of ASP.NET. This sets up authentication, logging, metrics, and a bunch of other things. When using external libraries such as NServiceBus, Quartz or GraphQL, we wrap them in a system that allows us to easily set them up with the rest of the system.

Your example takes advantage of C# closures and the fact that everything is in the same file. This is not something our applications can take advantage.

from nservicebus.

johnsimons avatar johnsimons commented on July 18, 2024

Hi @dnv-kimbell

Thanks for providing more context to this feature request.
We acknowledge that, currently, the API is not ideal for your scenario.
We will take this into consideration in an upcoming enhancement release.

Regards
John

from nservicebus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.