Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Neo4J Connector

Anypoint Connector for Neo4J provides the capability of execute CQL statements and run basic operations (such as create, update, delete, select nodes) against a Neo4J Graph DB instance.

See:

MuleSoft maintains this connector under the Connector Support Policy - Select.

This document assumes that you are familiar with Mule, Anypoint Connectors, Anypoint Studio, Mule Concepts, and Global Elements.

For hardware and software requirements, see the Neo4J Connector Release Notes.

How to Install

You can install the connector in Anypoint Studio using the instructions in Installing a Connector from Anypoint Exchange.

If you are upgrading from a previous version of the connector, a small popup appears in the bottom right corner of Anypoint Studio with the "Updates Available" message. Click the popup and follow the prompts to install the latest version.

Connector Namespace and Schema

When designing your application in Anypoint Studio, when you drag the connector from the palette onto the Anypoint Studio canvas, Studio automatically populates the XML code with the connector namespace and schema location.

  • Namespace: http://www.mulesoft.org/schema/mule/neo4j

  • Schema Location: http://www.mulesoft.org/schema/mule/neo4j/current/mule-neo4j.xsd

If you are manually coding the Mule application in Studio’s XML editor or another text editor, define the namespace and schema location in the header of your Configuration XML, inside the <mule> tag.

         
      
1
2
3
4
5
6
7
8
9
10
11
12
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:connector="http://www.mulesoft.org/schema/mule/neo4j"
      xsi:schemaLocation="
               http://www.mulesoft.org/schema/mule/core
               http://www.mulesoft.org/schema/mule/core/current/mule.xsd
               http://www.mulesoft.org/schema/mule/neo4j
               http://www.mulesoft.org/schema/mule/neo4j/current/mule-neo4j.xsd">

      <!-- put your global configuration elements and flows here -->

</mule>

Note: Use current in the schema path. Studio interprets this to the current Mule version.

Maven Dependency Information

For Maven dependency management, include this XML snippet in your pom.xml file.


         
      
1
2
3
4
5
<dependency>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-module-neo4j</artifactId>
    <version>2.0.0</version>
</dependency>

How to Configure

Place the connector in your flow as applicable for your use case.

To use the Neo4J connector in your Mule application, you must configure a global Neo4J element that can be used by the Neo4J connector. The Neo4J connector provides the following global configuration, requiring the following information:

Field Description

Username

Enter the username to log in with.

Password

Enter the corresponding password.

BOLT URL

Bolt endpoint.

REST URL

Rest endpoint URL (works with HTTP or HTTPS).

neo4j-global-element-props

Operations

Name Description

Execute

Execute any CQL statement against DB.

Create Node

Create a node with a specific initial label. Optionally, properties for the node can be added.

Select Nodes

Query nodes with a specific label. Optionally, properties used as filter can be provided.

Update Nodes

Modified properties for one or multiple nodes with a specific label. Optional Properties can be added as search filter criteria.

Delete Nodes

Delete one or multiples nodes based on a specific label. This lets you delete nodes with inbound/outbound relationships. Optional Properties can be added as search filter criteria.

For a full list of operations for any version of the connector, see the Neo4J Connector Reference.

Common Use Cases

Node Basic Create, Read, Update, and Delete

Example Flow
  1. Create a new Mule Project in Anypoint Studio and set your Neo4J environment properties in src/main/resources/mule-app.properties.

    
                 
              
    1
    2
    3
    4
    
    config.username=<USERNAME>
    config.password=<PASSWORD>
    config.boltUrl=<BOLT_URL_ENDOPOINT>
    config.restUrl=<REST_URL_ENDPOINT>
  2. Drag an HTTP connector onto the canvas and configure it with the default values.

  3. Drag a Transform Message onto the canvas and create a flowVar called 'params' with the following code:

    
                 
              
    1
    2
    3
    4
    5
    6
    7
    
    %dw 1.0
    %output application/java
    ---
    {
            "name":"Tom Hanks",
            "born": 1956
    }
  4. Drag the Neo4J connector onto the canvas and configure a new Global Element according to the table below:

    Parameter Value

    Username

    ${neo4j.username}

    Password

    ${neo4j.password}

    BOLT URL

    ${neo4j.boltUrl}

    REST URL

    ${neo4j.restUrl}

    <neo4j:config name="Neo4j__Basic_Authentication" username="${neo4j.username}" password="${neo4j.password}" boltUrl="${neo4j.boltUrl}" restUrl="${neo4j.restUrl}" doc:name="Neo4j: Basic Authentication"/>
    1. In the Properties Editor, configure:

      Parameter Value

      Display Name

      Create node

      Connector Configuration

      Neo4j__Basic_Authentication

      Operation

      Create node

      Label

      Person

      Parameters Reference

      #[payload]

      Create node

      Note: Click Test Connection to confirm that Mule can connect with the Neo4J instance. If the connection is successful, click OK to save the configuration. Otherwise, review or correct any invalid parameters and test again.

  5. Drag a Neo4J connector onto the canvas, in the Properties Editor, configure the parameters:

    Parameter Value

    Operation

    Select nodes

    Label

    Person

  6. Drag a Neo4J connector onto the canvas, in the Properties Editor, configure the parameters:

    Parameter Value

    Operation

    Delete nodes

    Label

    Person

  7. Drag an Object to JSON onto the canvas.

  8. Save the changes and deploy the project as a Mule Application. Open a browser and make a request to the following URL:

    http://localhost:8081/CRUD

    If the node was successfully created and deleted, information should be displayed in a JSON format:

    [{"a":{"born":1956,"name":"Tom Hanks"}}]

Connector Performance

To define the pooling profile for the connector manually, access the Pooling Profile tab in the global element for the connector.

For background information on pooling, see Tuning Performance.

See Also