...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
XPathBuilder xpath = new XPathBuilder("/rdf:RDF/rdf:Description/rdf:type[@rdf:resource='http://fedora.info/definitions/v4/indexing#Indexable']")
xpath.namespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
from("activemq:topic:fedora")
.to("fcrepo:localhost:8080/fedora/rest")
.filter(xpath)
.to("fcrepo:localhost:8080/fedora/rest?transform=default")
.to("http4:localhost:8080/solr/core/update"); |
In this specific case, the XPath filtering predicate is just an example; you can, of course, use many different Predicate languages, including XQuery, SQL or various Scripting Languages.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<route>
<from uri="activemq:topic:fedora"/>
<to uri="fcrepo:localhost:8080/fedora/rest"/>
<filter>
<xpath>/rdf:RDF/rdf:Description/rdf:type[@rdf:resource='http://fedora.info/definitions/v4/indexing#Indexable']</xpath>
<to uri="fcrepo:localhost:8080/fedora/rest?transform=default"/>
<to uri="http4:localhost:8080/solr/core/update"/>
</filter>
</route> |
Or, in Scala:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
val xpath = new XPathBuilder("/rdf:RDF/rdf:Description/rdf:type[@rdf:resource='http://fedora.info/definitions/v4/indexing#Indexable']")
xpath.namespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
"activemq:topic:fedora" ==> {
to("fcrepo:localhost:8080/fedora/rest")
filter(xpath) {
to("fcrepo:localhost:8080/fedora/rest?transform=default")
to("http4:localhost:8080/solr/core/update")
}
} |
Please note that the hostnames used for Fedora and Solr in the snippets above are arbitrary. It is quite likely that these systems will be deployed on separate hosts and that the Camel routes will be deployed on yet another host. Camel makes it easy to distribute applications and replicate data asynchronously across an arbitrarily large number of independent systems.
...
ActiveMQ brokers support a wide variety of protocols. If Fedora's internal broker is bridged to an external broker, please remember to enable the proper protocols on the remote broker. This can be done like so:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613"/>
</transportConnectors> |
Each transportConnector
supports many additional options that can be added to this configuration.
...
Camel routes can be deployed in any JVM container. In order to deploy to Jetty or Tomcat, the route must be built as a WAR file. This command will get you started:
Code Block | ||
---|---|---|
| ||
$> mvn archetype:generate \
-DarchetypeGroupId=org.apache.camel.archetypes \
-DarchetypeArtifactId=camel-archetype-war \
-DarchetypeVersion=2.14.0 \
-DgroupId=org.example.camel \
-DartifactId=my-camel-route \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=org.example.camel |
After the project has been built (mvn install
), you will find the WAR file in ./target
. That file can simply be copied to the webapps
directory of your Jetty/Tomcat server.
...
- downloading Karaf 4.x or later from an apache.org mirror
- running ./bin/karaf to enter the shell
installing required bundles:
Code Block language bash title Karaf console $> feature:repo-add camel 2.16.2 $> feature:repo-add activemq 5.11.1 $> feature:install camel $> feature:install activemq-camel # display available camel features $> feature:list | grep camel # install camel features, as needed $> feature:install camel-http4 # install fcrepo-camel (as of v4.4.0) $> feature:repo-add mvn:org.fcrepo.camel/fcrepo-camel/4.4.0/xml/features $> feature:install fcrepo-camel
setting up a service wrapper (so that karaf runs as a system-level service)
Code Block language bash title Karaf console $> feature:install wrapper $> wrapper:install
- following the directions provided by this command
...
Code Block | ||||
---|---|---|---|---|
| ||||
# install fcrepo-camel-toolbox (as of v4.1.0) $> feature:repo-add mvn:org.fcrepo.camel/fcrepo-camel-toolbox/4.1.0/xml/features # install fcrepo-camel-toolbox (as of v4.5.0) $> feature:repo-add mvn:org.fcrepo.camel/toolbox-features/4.5.0/xml/features # display available features $> feature:list | grep fcrepo # install feature $> feature:install fcrepo-indexing-triplestore |
Monitoring Your Camel Routes
...
Code Block | ||||
---|---|---|---|---|
| ||||
$> feature:repo-add hawtio 1.4.29
$> feature:install hawtio |
Once deployed, hawtio is available at http://localhost:8181/hawtio/
...