Andrej Koelewijn

  • Home
  • About
  • Departments
    • cloud
    • java
    • mobile
    • open standards
    • oracle
    • oss
    • other
    • soa
    • software development
    • tablet
    • Uncategorized
    • web
  • Subscribe via RSS

Simple Camel DSL OSGi Bundle example

October 19th, 2008  |  Published in java, soa  |  1 Comment

Here’s a simple example how you can create a Camel Route using it’s DSL, and deploy it as an OSGi bundle in the ServiceMix Kernel.

I’ll start with the java class that builds the camel routes. The following class, nl.iteye.camelbundle1.FileRouteBuilder configures a route that will copy any file from /tmp/src to /tmp/dest.


package nl.iteye.camelbundle1;

import org.apache.camel.builder.RouteBuilder;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class FileRouteBuilder extends RouteBuilder {
private static final transient Log LOG = LogFactory.getLog(FileRouteBuilder.class);

public void configure() {
LOG.info("configuring routes");
from("file:///tmp/src").to("file:///tmp/dest");
}
}

I’m going to create an OSGi bundle which can be deployed in the Servicemix kernel. An OSGi bundle is basically a jar file with a special manifest file. The following code shows the META-INF/manifest.mf file.


Manifest-Version: 1.0
Bundle-Name: camel-bundle-1
Bundle-SymbolicName: camel-bundle-1
Bundle-Version: 1.0.0
Bundle-Description: Camel Bundle 1
Bundle-Vendor: IT-eye
Bundle-Category: example
Import-Package: org.osgi.framework, org.apache.commons.logging, org.apache.camel.builder, org.apache.camel.model

When you deploy a bundle in Servicemix, Spring looks for META-INF/spring/*.xml files which can contain camel routes. In the following file i’m telling spring to look in the package nl.iteye.camelbundle1 for classes. This way my FileRouteBuilder class will automatically be run when the bundle is started.


<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

http://activemq.apache.org/camel/schema/spring

http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

<camelContext xmlns="http://activemq.apache.org/camel/schema/spring" >
<package>nl.iteye.camelbundle1</package>
</camelContext>
</beans>

Next I’m using a simple ant script to compile and jar the above files. The resulting jar can be installed in ServiceMix.

Before you can install the bundle, you need to install some required bundles, as is described here: Apache ServiceMix Kernel and Camel. You can verify the bundles installed correctly using osgi list command in ServiceMix kernel. The result should show the following modules:


[  29] [Active     ] [   50] camel-core (1.4.0)
[  30] [Active     ] [   50] camel-spring (1.4.0)
[  31] [Active     ] [   50] spring-tx (2.5.5)

Now i can install the bundle i’ve created as follows:


servicemix> osgi install file:///tmp/osgi/camel-bundle-1.jar
Bundle ID: 68
servicemix> osgi start 68

Test it by creating a file in /tmp/src.

Share and Enjoy:
  • del.icio.us
  • Google Bookmarks
  • DZone
  • SphereIt
  • StumbleUpon
  • Technorati
  • LinkedIn
  • HackerNews
  • PDF
  • Digg
  • Facebook
  • FriendFeed
  • Posterous
  • Tumblr
  • Twitter
  • RSS

View Comments

Feed Trackback Address
  1. SOA is not dead, were still in the early adaptor fase :: Andrej Koelewijn says:

    January 6th, 2009 at 8:22 pm (#)

    [...] lesson here: experiment and learn before you try to standardize. Just look at a framework like Apache Camel and you know that it can do many things better than BPEL. OSGI is also proving to be useful when [...]

Leave a Response

blog comments powered by Disqus

Tags

bi bpel camel cep css dsl esb esper google governance grails groovy gtalk html5 innovation internet ipad ivy java javascript jaxrs jersey jigsaw jquery linkeddata linux maven middleware mule noiv openoffice openweb oracle osgi oss plsql rdbms rest soa sql sun tablet web 2.0 xmpp yql

Archives

  • August 2010
  • June 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Recent Posts

  • Nice Java Decompiler tool: JD
  • VMware Player: The virtual machine is busy.
  • Adding a maven repository for installing features to ServiceMix
  • Upgrade Apache Camel in ServiceMix to version 2.3.0
  • A composite Rest service using Apache Camel

Categories

  • cloud
  • java
  • mobile
  • open standards
  • oracle
  • oss
  • other
  • soa
  • software development
  • tablet
  • Uncategorized
  • web

Recent Comments

  • Buddhika on Using google talk from java example
  • Anonymous on A composite Rest service using Apache Camel
  • Guest on How to find true cause of com.sun.star.uno.RuntimeException?
  • Absent Code attribute in method that is not native or abstract « Gooder Code - web development blog, php, java, asp.net, html, javascript on Absent Code attribute in method that is not native or abstract
  • Rmfume on Oracle best thing that could happen to JavaFX?
Buzz
andrkoel: RT @monkchips: James Governor's Monkchips » Day of The Dead: Web Drives Strong Demand for Java Skills http://monk.ly/d4UlND
1 hours ago, comment
andrkoel: RT @monkchips: In which my business partner @sogrady explains Why You Should Pay Attention to Node.Js http://monk.ly/a4aGIP serverside # ...
7 hours ago, comment
andrkoel: RT @stilkov: http://bit.ly/cDdqgl - AWS Identity and Access Management — I'd hate to have to compete against Amazon's Cloud offerings
13 hours ago, comment
andrkoel: Twitter for ipad is nice, but i still think i need a tool to summarize all info, something like feedly or flipboard is the future
8:36 AM Sep 02, 2010, comment
andrkoel: Trying out the new twitter for ipad... Curious how the panels work.
8:32 AM Sep 02, 2010, comment
 


©2010 Andrej Koelewijn
Powered by WordPress using the Gridline Lite theme by Graph Paper Press.