July 2017
Intermediate to advanced
414 pages
11h 18m
English
Adding a new custom module to the Spring Boot application is not so complex. For demonstrating this feature, assume that if a service gets more than two transactions in a minute, then the server status will be set as Out of Service.
In order to customize this, we have to implement the HealthIndicator interface, and override the health method. The following code is a quick and dirty implementation to do the job:
class TPSCounter { LongAdder count; int threshold = 2; Calendar expiry = null; TPSCounter(){ this.count = new LongAdder(); this.expiry = Calendar.getInstance(); this.expiry.add(Calendar.MINUTE, 1); } boolean isExpired(){ return Calendar.getInstance().after(expiry); } boolean isWeak(){ return (count.intValue() ...Read now
Unlock full access