In this article, I will explain how to execute a Java method once or on Mulesoft Application Startup. With this approach, we can add or execute some needed tasks before a Mule Application fully deployed such as User Notification or Data Clean-Up (Truncation of Database Tables or purging of files from the temporary storage within the server).
First, we need to create a Custom Java Class that implements the interface MuleContextNotificationListener and override the onNotification() method. We also need to make sure that our startup logic should run after the Mule Context started. https://goo.gl/2esdQ5