Among the various services offered on Bluemix, the Java Cloudant boilerplate is one of the most well-known and used. This boilerplate provides a web starter application. Just like any boilerplate, the application aims to provide a useful example of how the service can be used and the possibility to create your own application by modifying the code and then using a push onto Bluemix.
Quite common among the various applications available on Bluemix, is the absence of an auxiliary process that runs periodically, as is the case with the sample application provided by new Java Workload Scheduler boilerplate.
How can you create periodic processes on Bluemix?
In order to answer this question, we introduced an extended version of the Java Cloudant boilerplate. In addition to the Liberty Java Runtime and the database, you now have the Workload Scheduler service included. You can create various types of processes and schedule them to run when needed. You can then integrate them into your application to fully automate it.
What is new in the sample application within the boilerplate?
The sample application provided with the boilerplate shows how a favorite organizer can be set up and and how you can load files from your computer and organize them into categories. After creating a category, you can also modify it or eliminate it altogether. In this case, the application lacked a cleanup process aimed at clearing the database of obsolete files.
The following diagram illustrates the architecture of the application and how the services of the new boilerplate can be used to address the cleanup process. The cleanup process consists of two parts: the development of APIs that run on the runtime Liberty, and the creation and scheduling of a process that uses such APIs through the Workload Scheduler service.
Let’s take a minute to describe the two components by taking a look at parts of the sample code.
The Cleanup APIs use a methodology based on erasing database files that were loaded into the favorite organizer and that have not been used in two days.
Creating the process on Workload Scheduler
The following code illustrates how to use Java APIs to create and easily trigger a process using the Workload Scheduler service.
A process is made of steps that define the actual action to be executed. In this case, a REST Call step was created in order to invoke the Cleanup API that was developed. After the step was created, it was added to the process and then triggered to be processed daily.
What else can you do with the Workload Scheduler service?
The Java APIs available to developers allow them to create various kinds of steps that can be useful in an application. The types of steps currently available are:
- Command. This step is supported if you install your own agent.
- REST call
- File transfer
- Remote command
- WebSphere® MQ
The API Client Libraries are under constant development and are updated frequently. New types of steps are being added all the time.
It is also possible to trigger the process in various ways by simply using the TriggerFactory class methods and defining the process execution frequency and time.
Moreover it is possible create processes without use the client libraries but only on the Application Lab UI.
IBM Workload Scheduler extension of the Cloudant Java Boilerplate on Bluemix, it's a winning combination to building and automating your applications quickly and easily.
For more details about the Workload Scheduler service on Bluemix go to: