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
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

  • 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

  • Getting started with Nexus maven repository manager
  • JEE CDI tip: Target Unreachable, identifier resolved to null
  • Absent Code attribute in method that is not native or abstract
  • Prezi presentation software needs to add visual
  • So you think it’s the iPad that’s missing features?

Categories

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

Recent Comments

  • andrej on So you think it’s the iPad that’s missing features?
  • Dave on So you think it’s the iPad that’s missing features?
  • andrej on So you think it’s the iPad that’s missing features?
  • Fernando on So you think it’s the iPad that’s missing features?
  • andrej on So you think it’s the iPad that’s missing features?

RSS Friendfeed

  • Amerikanen rangschikken Rotterdams MVRDV in top 50 March 9, 2010
    andrej koelewijn Amerikanen rangschikken Rotterdams MVRDV in top 50 - http://www.idealize.nl/2010... 15 hours ago from Google Reader - Comment - Like […]
    FriendFeed
  • Getting started with Nexus maven repository manager March 9, 2010
    andrej koelewijn Getting started with Nexus maven repository manager - http://www.andrejkoelewijn.com/wp... 15 hours ago from Google Reader - Comment - Like […]
    FriendFeed
  • @eelzinga Did you add the remote repository to the correct reposutory group in nexus? http://bit.ly/a2gTmZ March 9, 2010
    andrej koelewijn @eelzinga Did you add the remote repository to the correct reposutory group in nexus? http://www.andrejkoelewijn.com/wp... 15 hours ago from Twitter - Comment - Like […]
    FriendFeed
  • Getting started with Nexus maven repository manager March 9, 2010
    andrej koelewijn Getting started with Nexus maven repository manager - http://www.andrejkoelewijn.com/wp... 15 hours ago from Andrej Koelewijn - Comment - Like […]
    FriendFeed
  • Re: 7 Reasons For Apple To Acquire Adobe March 7, 2010
    andrej koelewijn Re: 7 Reasons For Apple To Acquire Adobe - http://thenextweb.com/apple... Saturday from Disqus - Comment - Like "Seems to me you left out the most important reason: ipad will be about media convergence: combining books with magazines, newspapers, tv and internet. Currently adobe seems to have the best tools to create these new types of […]
    FriendFeed
  • Do we need a new tech literacy? (Behind the “big data” services like Twitter, Facebook use) March 6, 2010
    andrej koelewijn Do we need a new tech literacy? (Behind the “big data” services like Twitter, Facebook use) - http://scobleizer.com/2010... Saturday from Google Reader - Comment - Like […]
    FriendFeed
  • Pivot: Business intelligence meets the internet as a database http://bit.ly/bFc6wp March 6, 2010
    andrej koelewijn Pivot: Business intelligence meets the internet as a database http://infosthetics.com/archive... Saturday from Twitter - Comment - Like […]
    FriendFeed
  • Live Labs Pivot: A Massive Interactive Zoom on Data (TED Talk) March 6, 2010
    andrej koelewijn Live Labs Pivot: A Massive Interactive Zoom on Data (TED Talk) - http://infosthetics.com/archive... Saturday from Google Reader - Comment - Like […]
    FriendFeed
  • http://twitpic.com/16ykk7 - March 6, 2010
    andrej koelewijn http://twitpic.com/16ykk7 - Saturday from Twitter - Comment - Like […]
    FriendFeed
  • http://twitpic.com/16y8ve - #vuurtoren #scheveningen March 6, 2010
    andrej koelewijn http://twitpic.com/16y8ve - #vuurtoren #scheveningen Saturday from Twitter - Comment - Like […]
    FriendFeed


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