Implement a Notification Application for Monitoring Java Apps
- How to configure a custom application to notify you of critical metrics of Java applications via e-mail or SMS.
- How to use the custom application to take self-healing actions by restarting the specified Java applications running in the Neo environment.
Prerequisites
- To test the entire scenario, you need subaccounts in two regions: Europe (Rot/Germany) and US East. For more information, see Regions and Hosts Available for the Neo Environment and SAP BTP Cockpit.
- To retrieve the metrics of Java applications as shown in this scenario, you need two deployed and running Java applications. For more information, see Java: Application Operations.
- You have installed Maven.
- You have downloaded and set up your Eclipse IDE, SAP BTP Tools for Java, and SDK.
For more information, see Setting Up the Development Environment.
In this tutorial, you implement a notification application that requests the metrics of the following Java applications (running in SAP BTP, Neo environment):
-
app1
located ina1
subaccount andEurope (Rot/Germany)
region -
app2
located ina2
subaccount andUS East
region
Since the requests are sent to only two applications, the Maven project that you import in Eclipse only spawns two threads. However, you can change this number in the
MetricsWatcher
class, where theScheduledThreadPoolExecutor(2)
method is called. Furthermore, if you decide to change the list of applications, you also need to correct the list in theDemo
class of the imported project.
When the notification application receives the Java application metrics, it checks for critical metrics. The application then sends an e-mail or SMS, depending on whether the metrics are received as critical once or three times. In addition, the notification application restarts the Java application when the metrics are detected as critical three times.
To learn more about the whole scenario, read the Notification Scenario blog post.
If a Java application isn’t started yet, the notification application automatically triggers the start process.