camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Spring Neo4j
Date Tue, 12 Mar 2013 09:24:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Spring+Neo4j">Spring
Neo4j</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (4)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-changed-lines" >h2. Camel <span class="diff-added-words"style="background-color:
#dfd;">Spring</span> Neo4j component <br></td></tr>
            <tr><td class="diff-unchanged" > <br>*Available as of Camel
2.11* <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span
class="diff-added-chars"style="background-color: #dfd;">spri</span>n<span class="diff-added-chars"style="background-color:
#dfd;">g-n</span>eo4j:http://hostname[:port]/database?options</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">from(&quot;timer://foo?period=1000&quot;).to(&quot;<span
class="diff-added-chars"style="background-color: #dfd;">spri</span>n<span class="diff-added-chars"style="background-color:
#dfd;">g-n</span>eo4j:http://localhost:7474/data&quot;)</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >		exchange.getIn().setBody(exchange.getIn().getHeader(&quot;CamelFileName&quot;));
<br>	} <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">}).to(&quot;<span
class="diff-added-chars"style="background-color: #dfd;">spri</span>n<span class="diff-added-chars"style="background-color:
#dfd;">g-n</span>eo4j:http://localhost:7474/data&quot;)</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="SpringNeo4j-CamelSpringNeo4jcomponent"></a>Camel Spring
Neo4j component</h2>

<p><b>Available as of Camel 2.11</b></p>

<p>The <b>neo4j:</b> component allows you to treat Neo4j as a camel producer
endpoint. This means you can use this component in to() calls but not from() calls. This component
is backed by the <a href="http://www.springsource.org/spring-data/neo4j" class="external-link"
rel="nofollow">Spring Data Neo4j Library</a>.</p>

<ul>
	<li>As a producer, can create or remove nodes, and create or remove relationships.</li>
	<li>Can support as many endpoints as required, eg for multiple databases across multiple
instances.</li>
	<li>Headers set for node id (for created nodes), relationship id (for created relationships)</li>
</ul>


<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-spring-neo4j<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h3><a name="SpringNeo4j-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
spring-neo4j:http:<span class="code-comment">//hostname[:port]/database?options</span>
</pre>
</div></div>

<p>Where the URL is the location of the of running neo4j rest server.</p>

<h3><a name="SpringNeo4j-Headers"></a>Headers</h3>

<p>The following headers are set on exchanges during message transport.</p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Value </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>Neo4jOperation</tt> </td>
<td class='confluenceTd'> One of the Neo4jOperation enum values `CREATE_NODE, REMOVE_NODE,
CREATE_RELATIONSHIP, REMOVE_RELATIONSHIP` which determines which action to perform </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Neo4jNodeId</tt> </td>
<td class='confluenceTd'> the id of the created node </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Neo4jRelationshipId</tt> </td>
<td class='confluenceTd'> the id of the created relationship </td>
</tr>
</tbody></table>
</div>
</div>

<p>The producer will set the headers for downstream processors once the operation has
taken place. Any ID headers set prior to the producer are ignored.</p>

<h3><a name="SpringNeo4j-Operations"></a>Operations</h3>

<p>The neo4j component looks for the Neo4jOperation header to determine what kind of
entity to create, which is one of the following enum types</p>

<p>`CREATE_NODE, REMOVE_NODE, CREATE_RELATIONSHIP,	REMOVE_RELATIONSHIP`</p>

<p>The body of the message is used to determine the node or relationship to manipulate.
The following body types are supported:</p>

<p>For CREATE_NODE:</p>

<ul>
	<li>null body - create default node</li>
	<li>Map body - create node with the properties set from the map</li>
</ul>


<p>For REMOVE_NODE:</p>

<ul>
	<li>Long or Integer - remove node using the body as the id</li>
	<li>neo4j Node instance - remove the node specified by that instance</li>
</ul>


<p>For CREATE_RELATIONSHIP:</p>

<ul>
	<li>SpringDataRelationship - create relationship specified by any @NodeEntity annoted
Spring entities.</li>
	<li>org.apache.camel.component.neo4j.BasicRelationship - create relationship specified
by the neo4j node types</li>
</ul>


<p>For REMOVE_RELATIONSHIP:</p>

<ul>
	<li>Long or Integer - remove relationship using the body as the id</li>
	<li>SpringDataRelationship - remove relationship specified by the @NodeEntity annoted
Spring entities.</li>
	<li>org.apache.camel.component.neo4j.BasicRelationship - remove relationship specified
by the neo4j node types</li>
</ul>


<h3><a name="SpringNeo4j-Samples"></a>Samples</h3>

<p>If you wanted to insert a new empty node every 1 seconds</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"timer:<span class="code-comment">//foo?period=1000"</span>).to(<span
class="code-quote">"spring-neo4j:http://localhost:7474/data"</span>)</span>
</pre>
</div></div>

<p>If you wanted to delete a specific node specified by a filename, eg a file of 100
would delete node 100.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"file:/<span class="code-keyword">var</span>/data"</span>).process(<span
class="code-keyword">new</span> Processor() {
	@Override
	<span class="code-keyword">public</span> void process(Exchange exchange) <span
class="code-keyword">throws</span> Exception {
		exchange.getIn().setBody(exchange.getIn().getHeader(<span class="code-quote">"CamelFileName"</span>));
	}
}).to(<span class="code-quote">"spring-neo4j:http:<span class="code-comment">//localhost:7474/data"</span>)</span>
</pre>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Spring+Neo4j">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=30149721&revisedVersion=6&originalVersion=5">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Spring+Neo4j?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message