Mongohq

I was pointed to MongoHQ while reading the YCombinator Demo Day post and once you get past all the Groupon wannabe’s for another sector then you actually see some interesting things.

I’ve spent a lot of time looking over cloud document stores for transaction data to be involved with various uses.  So seeing MongoHQ was interesting and worthwhile to signup for.

This morning I needed to test the theory that I could ping sets of data to the cloud without any fuss.  An easy and trivial matter I thought, oh yes I’m sure.  So I wrote some Java code (no Ruby here lads 😉 and let it rip.  You can download the class I used to test with, I’m curious to see if others get the issue.  I’ve only tested this on my machine and not from other servers etc.

So assuming you have a MongoHQ account login and try the following:

i) Create your database, database user and a collection.

ii) Change the settings in the Java file and make sure that you’ve got the MongoDB JDBC driver.

iii) Run as is and it will report that 100 records have been issued. The WriteResult object reads any response and prints it.

iv) When I check on MongoHQ it says that only 43 records have been written to the database.

So how did I cure the problem?

One simple line in the method that closes the connection.  Thread.sleep(1500); pauses the thread for 1500 milliseconds before attempting to close the connection to MongoHQ.  Review the website again and 100 records have been written this time.

I have a one theory as to why this works with the paused thread.  I’m wondering if the inserts are queued with all the other requests on MongoHQ’s side but the connection close requests aren’t.  Once the connection goes then there’s nothing to write to.

One the whole I love how MongoHQ lets me do things, the interface is clean as well, not that I’d use that much but it’s there if I need it.  I’m just curious as to why this closing connection issue needs me to wait a second and a half before I can progress.

Questions, comments and general banter in the comments please.

 

Advertisements