2. We can easily initialize the database by using a Groovy script.
Let us consider we need to clear all the database value when our Mule application
will start in server.
3. Let us consider we have the following Mule flow, which will use the database
component to insert a new value into database table.
But we also require when this flow will start at server it will initialize the database by
clearing (deleting) the old values from the table
4. So, before we will start the flow in the server we will check the existing values in database
table which will be cleared when the application will be deployed into server:-
As you can see the current database table has the above rows which we need to clear
when our Mule application will be deployed
5. The corresponding Mule flow will be as follows:-
Here is you can we are using Groovy script which will call database query “Delete from table1” at the start of the
application
6. Now let’s start our application and deploy it into Mule server
So, you can see that whenever the Mule application is started the database is initialized at the
start and the data are cleared from the table
7. You can see now the table is empty and no data is there in database
8. And now if we hit http://localhost:8081/initial in our browser we will get the following
The Mule flow has inserted a new row in the database table
9. And if we check the database now, we will find a new row is inserted there in the Database table
10. In my next slide I will bring some other techniques in Mule implementation .
Hope you have enjoyed this simpler version.
Keep sharing your knowledge and let our Mule community grow