MongoHQ

MongoHQ

Last modified by Vivek Pandey on 2014/04/18 21:46

MongoHQ is a CloudBees Ecosystem partner who provides the hosted database solution for getting your applications up and running on MongoDB. By subscribing to this service on the ecosystem page, you can easily create and configure MongoDB databases as the data layer for your Cloudbees-hosted applications.

Subscribing to MongoHQ

You can subscribe to MongoHQ by reviewing the subscription page in the CloudBees Ecosystem, and clicking the subscribe button.  Please note that the MongoHQ base subscription is purely on-demand, so there is no cost for subscribing and you will be charged later if you create any upgraded MongoDB instances. 

After subscribing to MongoHQ, you can click the MongoHQ link (found on the CloudBees Services page) to create and manage the MongoDB instances attached to your account.

How to upgrade or downgrade MongoDB instance

You can upgrade your MongoDB instance from MongoDB management interface. Click on Edit button and choose the db plan to upgrade or downgrade to.

Creating a MongoDB instance

To create a new MongoHQ instance, click the Create button on the MongoHQ management interface.

Using a MongoDB instance from your application

The MongoDB management interface displays list of your MongoDB databases. As a quick way to get started, you can click on Show config link and then copy MongoHQ_URL into your application code.  However, the preferred way to access the MongoHQ_URL when deploying to RUN@cloud is to use the Bees SDK app:bind command:

bees app:bind  -a <YOUR_APP>   -r mongohq:<MONGOHQ_RESOURCE>   -as <ALIAS>

That will automatically create a configuration parameter (called MONGOHQ_URL_<ALIAS>) that you can reference from your application.  For example, assuming my MongoHQ resource is called "gasp" and my app is called "gasp-mongo", then the following command will create a binding with alias "GASP", and a corresponding environment variable MONGOHQ_URL_GASP with the MongoHQ connection string:

bees app:bind -a gasp-mongo  -r mongohq:gasp -as GASP

You can verify your configuration with the bees app:bindings and bees [SERVICE]:list commands, like so:

bees app:bindings -a gasp-mongo
bees mongohq:list

Now you can use e.g. System.getProperty("MONGOHQ_URL_GASP") to get the value of MONGOHQ_URL_GASP from the application's environment as described in this Configuration Parameters article.

Sample with the MongoDB Java Driver.

String uriAsString = System.getProperty("MONGOHQ_URL_GASP", "mongodb://localhost/local");
MongoClientURI uri = new MongoClientURI(uriAsString);
MongoClient mongoClient = new MongoClient(uri);
...
Tags:
Created by Spike Washburn on 2011/11/01 15:16