Author: Fuse Team
Level: Beginner
Technologies: Camel, Blueprint, JBoss Data Virtualization
Summary: Demonstrates how to use the camel-olingo2 component in Camel to integrate with JBoss Data Virtualization (JDV) using OData 2.0
Target Product: Fuse
Source: https://github.com/jboss-fuse/quickstarts
This quick start shows how to use Apache Camel, and its OSGi integration to use the OSGi config admin and create records in JDV.
This quick start combines use of the Camel JSON data format to read records from json files, and Camel Olingo2 component to create records in JDV.
In studying this quick start you will learn:
- how to define a Camel route using the Blueprint XML syntax
- how to build and deploy an OSGi bundle in JBoss Fuse
- how to use JSON data format in JBoss Fuse
- how to use OSGi config admin in JBoss Fuse
- how to use the Camel Olingo2 component for OData
For more information see:
- https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2/html/Apache_Camel_Component_Reference/files/_IDU_Olingo2.html for more information about the Camel Olingo2 component
- https://access.redhat.com/site/documentation/JBoss_Fuse/ for more information about using JBoss Fuse
Before building and running this quick start you need:
- Maven 3.1.1 or higher
- JDK 1.7 or 1.8
- JBoss Fuse 6
-
Create BOOKS OData service in JDV server by following the instructions at https://developer.jboss.org/wiki/ProducingAndConsumingODataInTeiidAndTeiidDesigner Note that if you are not using MySQL, change the uri in src/main/resources/OSGI-INF/blueprint/odata.xml to point to the correct OData service.
-
Change your working directory to
camel-odatadirectory. -
Run
mvn clean installto build the quickstart. -
Start JBoss Fuse 6 by running bin/fuse (on Linux) or bin\fuse.bat (on Windows).
-
Create the following configuration file in the etc/ directory of your Red Hat JBoss Fuse installation:
InstallDir/etc/org.jboss.quickstarts.fuse.camel-odata.cfg Edit the org.jboss.quickstarts.fuse.camel-odata.cfg file with a text editor and add the following contents:
userPassword=Basic serviceUri=http://localhost:8080/camel-odata/BooksRest contentType=application/atom+xml;charset=utf-8
-
In the JBoss Fuse console, enter the following commands:
features:install camel-olingo2 features:install camel-jackson osgi:install -s mvn:org.jboss.quickstarts.fuse/camel-odata/${project.version} -
Fuse should give you an id when the bundle is deployed
-
You can check that everything is ok by issuing the command:
osgi:listyour bundle should be present at the end of the list
To use the application be sure to have deployed the quickstart in Fuse as described above.
- As soon as the Camel route has been started, you will see a directory
work/camel-odata/inputin your JBoss Fuse installation. - Copy the files you find in this quick start's
src/main/resources/datadirectory to the newly createdwork/camel-odata/inputdirectory. - Use
log:displayto check out the business logging. Receiving file book1.json Sending file book1.json to JBoss Data Virtualization Server Done creating book with ISBN 0-042-123456 - To re-run the example using the same sample data, delete the records created in the previous run
To stop and undeploy the bundle in Fuse:
-
Enter
osgi:listcommand to retrieve your bundle id -
To stop and uninstall the bundle enter
osgi:uninstall <id>