Bluemix.info uses Cloudant NoSQL Database for Bluemix as datastore. There is a lot of great information out there about Cloudant in general, e.g. the IBM Cloudant web site and about Cloudant on Bluemix, e.g. on developerWorks. Below is a high level overview how we use Cloudant in Bluemix.info.
We use the Java API Ektorp to access Cloudant from our Java application. Ektorp is available as open source under the Apache license and it’s part of the Liberty profile buildpack on Bluemix. The Bluemix.info application pulls down the library via Maven.
There are different ways how to access Cloudant databases and how to handle the configuration. The documentation on Bluemix.net describes how to bind databases to Liberty applications. We’ve used a slightly different approach. When running on Bluemix the configuration is read from the environment variable ‘VCAP_SERVICES’. In order to run and debug code locally we use local environment variables, primarily to be consistent how we run other Bluemix services locally.
In order to allow other developers to set up Bluemix.info themselves as easily as possible, we check whether the database already exists and if not we create it. Furthermore we create the design of the database programmatically. After this the design shows up in the Bluemix dashboard.
Reading from and writing to Cloudant is pretty straight forward via the APIs ‘db.update(feed)’, ‘db.create(newFeed.getId(), newFeed)’, ‘db.get(Feed.class, feedId)’, etc. Check out for example how we make feeds persistent. The feed class extends CouchDbDocument which is a convenience class that handles things like ids and revision ids.
Overall the experience to use Cloudant has been very positive for me personally and a lot of fun. It’s very easy to get started and fast to be productive.