10 Steps to run Spring Data Neo4j at OpenShift

It’s very easy to get Neo4j running on RedHat’s OpenShift Cloud Platform. Note that at the time of writing this, there is no Neo4j cartridge available at OpenShift.

If you are familiar with Heroku, think that a cartridge is like a Heroku Add-on. It plugs functionality into the PaaS environment.

So, how we can use Neo4j at OpenShift? First, remember to always read a README file, if there’s one.

When you create a project at OpenShift, a README file can be located at the root directory of your app. Among other things, we have this line:

../data – For persistent data (also in env var OPENSHIFT_DATA_DIR)

Hmmm that’s interesting! Heroku doesn’t have a place for persistent data across Heroku’s dynos. They are ephemeral, as said by James Ward, here.

From now on, you can guess what to do, right?

The answer is inside of Spring applicationContext.xml file:

<neo4j:config storeDirectory="${OPENSHIFT_DATA_DIR}/graph.db"/> 

To let things more easy, I built a OpenShift skeleton app so I don’t have to do it again and again..

You can view and fork it here: https://github.com/tomasmuller/openshift-neo4jtemplate

Oh! Almost forgot! You can read all the 10 steps of this post title, in the project README.md file!

;-)

About these ads