Contact Us 1-800-596-4880

Neo4J Connector

Select

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.

To Install this Connector

  1. In Anypoint Studio, click the Exchange icon in the Studio taskbar.

  2. Click Login in Anypoint Exchange.

  3. Search for the connector and click Install.

  4. Follow the prompts to install the connector.

When Studio has an update, a message displays in the lower right corner, which you can click to install the update.

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.
<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.

<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, 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.

    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:

    %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

View on GitHub