Our application should be "quiesced" when it is being removed from service from an ALB. I am aware that the http requests are "drained" from the terminating instance before it is removed, but we need the application to also stop handling/producing rabbitmq messages.
We already have scripts that we can ship within the application folder that an operator can execute if this needs to be done manually - they control the HTTPCode returned by the Health Check endpoint. These are useful if the application instance needs to tell the ALB to stop sending requests. But is there a way the ALB can inform the application to quiesce itself before it is terminated?
I'm also wondering if there is a way that the application can delay the terminate while it finishes up jobs or waits for requests to complete.
I'm particularly interested from the point of view of auto-scaling as there is no way in advance to know which instance will be terminated and thus an operator has no chance to run the scripts in advance