Explore the graph with Mule and Neo4j
The new connector, presented in this blog, allows Mule users to leverage the incredibly rich API that Neo4j offers with convenient configuration elements.
Mule has a very extensive support for NoSQL data stores, which covers pretty much the whole spectrum of what’s available out there, from key/value stores to document-oriented databases. The only piece that was missing in the puzzle was connectivity to a graph database: with the introduction of the Neo4j connector, the gap is now closed.
Popularized by the advent of social media, the need for efficiently storing, indexing, traversing and querying graphs of objects has become prominent in less than a decade. During this time, Neo4j has risen to the number one graph database on the market, with successful deployments across all types of industries and a strong commitment to open source.
The new connector, presented in this blog, allows Mule users to leverage the incredibly rich API that Neo4j offers with convenient configuration elements. Read on to discover a simple example built with this connector.
Loading sample data in Neo4j
In this example, we will use the dataset that Neo4j made public for the Hubway Data Challenge (Hubway is a bike sharing service which is currently expanding worldwide). We will expose a Cypher query as a basic HTTP resource: this query will let the caller retrieve the nearby Hubway stations and how “hot” they are (ie how much trips started or ended at these stations).
- Download the dataset: hubway_data_challenge_boston.zip
- Stop your Neo4j server
- In case you care, back-up your existing data, ie the
- Extract the zip file into
- Start the server again
- Browse the Neo4j dashboard and confirm you have ~500K nodes loaded as shown below:
Getting Mule Studio Ready
The Neo4j module doesn’t come bundled with Mule Studio so we have to install it first. For this, we have to do the following:
- Open Mule Studio and from “Help” menu select “Install New Software…”. The installation dialog – shown below – opens.
- From “Work with” drop down, select “MuleStudio Cloud Connectors Update Site”. The list of available connectors will be shown to you.
- Find and select the Neo4j module in the list of available connectors.
- When you are done selecting the Neo4j module, click on “Next” button. Installation details are shown on the next page. Click on “Next” button again and accept the terms of the license agreement.
- Click on “Finish” button. The Neo4j module is downloaded and installed onto Studio. You’ll need to restart the Studio for the installation to be completed.
Setting up the project
Now that we’ve got Mule Studio up and running, it’s time to work on the Mule Application. Create a new Mule Project by clicking on “File > New > Mule Project”. In the new project dialog box, the only thing you are required to enter is the name of the project: use “neo4j-example” or similar. You can click on “Next” to go through the rest of pages.