Thursday, January 24, 2013

Pros and Cons of merging web and backend java app on Cloudfoundry

For my application, there are two components. Web Application and background scheduled job . Web application is developed using Spring Roo and scheduled job is built using Spring batch.

Ideally I want to have these two separate projects and deployment for obvious reasons ! But here is problem, Spring-batch scheduled job requires two datasources. One for its own meta-data and other my primary transaction database.

My cloud environment is VMWare's cloudfoundry. When Cloud-foundry deployment environment detects there are two beans with javax.sql.Datasource, it can not auto-reconfigure the datasource to Cloudfoundry service.

In other words, if there is only one javax.sql.Datasource bean in your app, cloudfoundry automatically detects it and connects it to the database service instance. but if there are two beans like that , the code needs to specifically mention which database service each bean needs to use.

Thats where there is "cloud" namespace which you can specify cloud databases in XML itself. But as anybody can guess, once I have that code in XML, my app will stop working in local environment.

So for now, its better to merge my both apps as long as load on the apps is less.

My tweets on similar topics