dsatish
dsatish

Reputation: 1041

Java - Access to MongoDB server running on Windows Azure

I am developing an application that will use MongoDB running on Windows Azure. This page http://www.mongodb.org/display/DOCS/MongoDB+on+Azure on MongoDB refers to a VisualStudio solution that has helper classes to get access to the mongo server settings and for deploying/configuring mongo instances. Is there a Java based solution?

Upvotes: 2

Views: 220

Answers (1)

David Makogon
David Makogon

Reputation: 71030

Out of the box, the 10gen-provided solution is only a .net / Visual Studio version, which creates a Replica Set with several Worker Role instances. You'd then need to add additional Roles to run your app (such as an IIS-based web app in a Web Role, or a Tomcat-based Java app in a Worker Role).

The issue you'll run into: You'd need to:

  • Do your Java development in Eclipse
  • Generate the WAR file
  • Create your java scaffolding in a Worker Role in visual Studio which unzips Tomcat and the JRE, copies your WAR file to the appropriate directory, sets up the environment, and launches Tomcat.

If you want to forego Visual Studio altogether, you'd need to configure and launch mongod.exe from your Java startup script. When you create a Windows Azure project from Eclipse, you'll see that there are several sample startup scripts: one for JBoss, one for Tomcat, etc. Pick the one that matches what you're using, copying it over the main project startup script. Then you can customize it to grab mongod.exe and launch it. This should be pretty straightforward to create a standalone MongoDB instance, but you'd have lots of work to construct a replicaset. 10gen doesn't have an out-of-the-box Java project built already for this.

Upvotes: 1

Related Questions