Andrej Koelewijn

  • Home
  • About
  • Publications
  • Departments
    • agile
    • architecture
    • 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.

  • Pingback: SOA is not dead, were still in the early adaptor fase :: Andrej Koelewijn

Tags

activemq agile bi camel css esb google governance grails groovy gtalk html5 internet ipad ivy J2EE java javascript jaxrs jmx jquery lean linkeddata linux maven mule noiv openoffice opensource Open Source oracle osgi oss rdbms rest scrum servicemix soa sql svg tablet web 2.0 XML xmpp yql

Archives

  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • 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
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005

Meta

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

Recent Posts

  • Updating a vagrant box
  • Using littleproxy in Mule unit tests
  • Useful site to determine what html5, css3 & svg you can use
  • A Product Owner is a Project Manager
  • Using css webfonts in inkscape

Categories

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

Recent Comments

  • Pcdiggs on Software architecture, PHP and Javascript
  • Een Scrum Product Owner is een Project Leider on A Product Owner is a Project Manager
  • Using css webfonts in inkscape :: Andrej Koelewijn on Create presentations using inkscape
  • Create presentations using inkscape :: Andrej Koelewijn on Presentation: Introduction to Scrum
  • Gebhard Greiter on What is Agile?
Buzz
andrkoel: Utrecht hele dag mist, scheveningen zomerse dag... http://t.co/cDRCJHr9
4:35 PM Nov 10, 2011, comment
andrkoel: RT @stefanvdkamp: Beter filmpje van Garret McNamara in de 30 meter hoge golf. http://t.co/9abiWkYX
9:20 AM Nov 10, 2011, comment
andrkoel: Mmm, een uur voor den haag - leiden lijkt te weinig, ga mijn afspraak niet redden...
7:34 AM Nov 10, 2011, comment
andrkoel: Big Data is Useless without Science http://t.co/2I8EiLsH
6:18 AM Nov 10, 2011, comment
andrkoel: Just tried #vagrant to quickly setup virtualbox development environment. Looks good, although provisioning apache through puppet failed...
10:47 PM Nov 09, 2011, comment
 


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