Over a million developers have joined DZone.

Data Loading Neo4j Graphs From SQL Sources

DZone's Guide to

Data Loading Neo4j Graphs From SQL Sources

· Integration Zone ·
Free Resource

WSO2 is the only open source vendor to be named a leader in The Forrester Wave™: API Management Solutions, Q4 2018 Report. Download the report now or try out our product for free.

Neo4j is a powerful graph database that can be used for analytics, recommendation engines, social graphs and many more applications. In the following example we demonstrate in a few steps how you can load Neo4j from your legacy relations SQL source. If you need to get the mule studio: http://www.mulesoft.org/download-mule-esb-community-edition

Create a new mule project, and in the Mule flow:

  1. trigger an event from a web page. The default is http://localhost;8080
  2.  It will do a database query, in my case a simple Select
  3. Inline image 1
    3. Insert the returned map into Neo4j

    Inline image 4

    4.There are 3 lines of script to print the result

    import org.mule.modules.neo4j.model.Node
    Node myNode = payload
    System.err.println “Created node with id: ” + myNode.getId()
    In my console, I see the map of data extracted and then a node with properties created in Neo4j. Inline image 5 Some misc bits ... the choice block is there in the front because a browser will make 2 calls:
    • the first is a real page request
    • the second asks for the page browser icon “/favicon.ico”
    So the choice block filters this out to ensure that there is only 1 call.

    A real world application would probably use a polling even and have and split database records, or use Neo4j's bulk upload. However, I hope this gives you a taste of how easy integration can be. 

IAM is now more than a security project. It’s an enabler for an integration agile enterprise. If you’re currently evaluating an identity solution or exploring IAM, join this webinar.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}