Spring batch, Spring Scheduler, PCF

stlplace
Reading Time: < 1 minute

Was experimenting running scheduled job on PCF. One natural choice is PCF scheduler, which comes with the Pivotal Web Services (PAAS). Googled around and found this example on DZone. The spring batch code is here. There was a small typo in the manifest.yaml,

path: build/libs/payment-processing-spring-batch-0.0.1-SNAPSHOT.jar
Note the snapshot.jar file name does not match what’s specified in the build.gradle file.

The correct file name is

spring-batch-job-0.0.1-SNAPSHOT.jar

The rest of the manifest.yml looks good, in fact I used the following options for my spring scheduler app manifest.

no-hostname: true
no-route: true
health-check-type: none

But PCF scheduler is not available in our environment. The Spring Scheduler is used instead. I followed this Get Started Guide from Spring. In my case I need to use Cron Expression, here is the code sample and here is the guide to cron expression.

Last but not least, in my case I need to send out email notification for the cron job conditionally. I used the java email code sample here.

======

Some PCF references

pivotal web serivce

cf login -a https://api.run.pivotal.io/

https://console.run.pivotal.io/tools

https://docs.pivotal.io/pcf-dev/index.html

cf login -a api.local.pcfdev.io --skip-ssl-validation

https://tanzu.vmware.com/tutorials/getting-started/local/deploy-the-sample-app

%d bloggers like this: