micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.08k stars 1.07k forks source link

Support Graceful shutdown #10656

Open graemerocher opened 7 months ago

graemerocher commented 7 months ago

Feature description

Basically this is how it needs to work:

Other considerations:

We may want to make the implementation generic and not coupled to HTTP For example you may want to wait for active Kafka message consumers to complete and then shutdown Or you may want to wait for active scheduled jobs to complete and then shutdown Implementation should there for be defined with a generic registry of counters:

interface ActiveResources {
    boolean hasActive(ResourceKind kind);
    void start(ResourceKind resource);
    void stop(ResourceKind resource);
} 

enum ResourceKind {HTTP_REQUEST, JOB, MESSAGE};

We could then later update the other implementations (Kafka, JMS etc.) to support it.

yawkat commented 7 months ago

it actually isn't possible to make this a generic filter because there's no api atm to know when a http request has been fully sent to the client (not just queued).