By Justin Freeman
DynamoDB is Amazon’s version of a NoSQL database. Now normally like everyone in the Amazon web space, you have to develop your application remotely. And every developer knows that developing remotely is a huge pain.
Not only do you have to worry about network and speed issues, you also have to worry about racking up unnecessary costs developing DynamoDB. Amazon charges depending on how much space, network bandwidth etc, you use. Your application isn’t even in production!
Up until recently, using DynamoDB was no exception. But now you have DynamoDB Local!
DynamoDB Local is a fully functional, self-contained version of Amazon’s DynamoDB NoSQL database. It runs entirely on your local machine and does not require any of kind of internet connection to Amazon.
The best part is, you don’t get charged for transactions you run using the local version of DynamoDB. This keeps development costs way down. You can develop your application, run speed and load tests all the time without having to worry about being charged for the bandwidth. It really is the best of both worlds. You get to use a high-quality NoSQL database that will be situated in the cloud AND you can do full testing on your application BEFORE you release to AWS.
Getting Started with DynamoDB Local
It's fairly simple. Go to Amazon’s website and download the DynamoDB Local executable and install it along with the latest version of the JDK. Next, run the command below to bring up the database.
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 8888
This will start open DynamoDB on your machine at port 8888. Now to access the DynamoDB console, just go to http://localhost:8888/shell
Simply copy the command and paste it into the window above. That's it! You are not manipulating data and tables in your own DynamoDB database, and it isn’t costing you a thing!
Now that you have a local DynamoDB running on your local development environment, you can use Amazon’s Java API for DynamoDB to write your application to work with DynamoDB. To make it even easier, there is also a Spring community version for DynamoDB which allows you some JPA support.
Now I will warn you that support for JPA is not very robust. I ran into several issues using it. There were a few things that were just not supported. Keep in mind this a community version, therefore support for things is much slower. I ended up with the normal Java API developed by Amazon to use some of the more advanced features I needed in order to complete my application.
Welcome to the wonderful world of local development using DynamoDB. Enjoy!