Friday, December 16, 2011

Run a Google Web Toolkit 2 project on Apache Karaf/ServiceMix

To simplify the development of Web projects on Apache Karaf/Apache ServiceMix, we have created archetypes to setup WAR or WAB projects. They are very basic but they can be enriched with framework like Struts 2, Wicket, plain JSP or MyFaces JSF as they are currently supported on Apache Karaf - ServiceMix.

For the GWT users, it exists now an archetype which will create a GWT 2.4 project. To create such a project, you must generate a project from the archetype

mvn archetype:generate \
   -DarchetypeArtifactId=wab-gwt-archetype \
   -DarchetypeVersion=2.1.2 \
   -DgroupId=com.mycompany \
   -DartifactId=hello \

build next the WAB using hello/mvn clean install

and deploy it on Apache Karaf

Verify that the web site is well registered :

Next, you can navigate to your application in your browser and click on the button to say Hello.

Remark : A WAB project is nothing more than a WAR excepted it is packaged as a bundle file, that we have removed the WEB-INF/lib dependencies and create a MANIFEST file containing the OSGI instructions.

Monday, November 21, 2011

Apache Camel, Cxf, ActiveMQ & ServiceMix at Devoxx

This year, I get the chance to present 2 talks at the Devoxx event,

one for University Talk and the other for Hands on Lab. With the help of Gert Vanthienen, we took the time to present in more detail what finally we can design as solution, architecture with Apache projects like Camel, CXF, ActiveMQ and ServiceMix and move it into a scalable, high-available platform.

That was a great challenge as this is not really easy to introduce "integration" which is not so sexy comparing to a Web Development framework, an iPhone or Android application. But times are changing and a lot of developers / architects are interested by agile approaches that we develop at Apache foundation.

With Fuse IDE tool,we can now accelerate the creation of a project using Apache Camel. The wysiwig editor and EIPs patterns allow you to quickly create new routes while the runtime editor enable to review existing project. IDE is more than a tool as it allows to run and deploy the routes in Fuse ESB, Tomcat application servers or locally. The tool is not yet finalized (release 2.1 should be available soon) but it offers a lot of possibilities to facilitate integration projects, tracing of messages (= exchanges) and investigation about time passing through the different processors.

Integration projects are moving into cloud space and this is what we have presented next with FuseSource Fabric. Fabric is not a new hype but a strategy to reduce impact of OSGI dependencies calculation, provisioning of Apache Camel routes on local, remote or cloud instances using Apache Zookeeper as registry of artefacts to be deployed (features, jars, configurations). It offers also elastic services when deploying services into the cloud.

For those who were not there, here are the links of the presentation like also the hands on lab material that we have used in the afternoon to develop a real Japa Application Project (Spring, JPA, Web) on Fuse ESB.
Remark : The step by guide is available on the github repo like also the skeleton (zip file)

Thursday, February 24, 2011

Talks about Integration with Camel and ESB

This year, I plan to make some talks about Apache ServiceMix, Apache Camel, apache ActiveMQ and show how easy it is to build integration solutions with Apache technologies.

Take free time, a two break hours and joint me during one of the following events :


The purpose of this presentation/demo is to show you how easy it is to design integration between systems (web services, file systems, database, queue engine) using the projects Camel, ServiceMix and ActiveMQ of the foundation Apache.

First part :

Presentation of the projects Camel, ServiceMix and ActiveMq
Description of the topologies proposed : messaging, osgi, web, ...
High-availability and scalability (ServiceMix and/or ActiveMQ)

Second part :

Making of of the demo solution
Transpose it into camel DSL language
Coding of WebService (using Apache CXF), DAO and Persistence layer (Spring + Hibernate JPA) and Web layer (Apache Wicket),
Development of Camel routes,
Packaging and Deployment

Wednesday, February 23, 2011

Measure elapsed time with Camel

With the last version of Apache Camel, we provide a event notifier support class which allow to keep information about what happen on Exchange, Route and Endpoint. One of the benefit of this class is that you can easily audit messages created in Camel Routes, collect information and report that in log by example.

When developing an application, it is very important to calculate/measure elapsed time on the platform to find which part of your code, processor or system integrated which is the bad duck and must be improved.

In three steps, I would show you How to enable this mechanism to report :
- Time elapsed to call an endpoint (could be another camel route, web service, ...)
- Time elapsed on the route exchange

STEP 1 - Create a Class implementing the EventNotifierSupport

public class AuditEventNotifier extends EventNotifierSupport {

public void notify(EventObject event) throws Exception {
if (event instanceof ExchangeSentEvent) {
ExchangeSentEvent sent = (ExchangeSentEvent) event;">>> Took " + sent.getTimeTaken() + " millis to send to external system : " + sent.getEndpoint());

if (event instanceof ExchangeCompletedEvent) {;
ExchangeCompletedEvent exchangeCompletedEvent = (ExchangeCompletedEvent) event;
Exchange exchange = exchangeCompletedEvent.getExchange();
String routeId = exchange.getFromRouteId();
Date created = ((ExchangeCompletedEvent) event).getExchange().getProperty(Exchange.CREATED_TIMESTAMP, Date.class);
// calculate elapsed time
Date now = new Date();
long elapsed = now.getTime() - created.getTime();">>> Took " + elapsed + " millis for the exchange on the route : " + routeId);

public boolean isEnabled(EventObject event) {
return true;

protected void doStart() throws Exception {
// filter out unwanted events

protected void doStop() throws Exception {
// noop


Not really complicated and the code is explicit. Check the doStart() method to enable/disable the events for which you would like to gather information.

This example uses only Exchange.CREATED_TIMESTAMP property but the next version of Camel 2.7.0 will provide you the property exchange.RECEIVED_TIMESTAMP and so you will be able to calculate more easily the time spend by the exchange to call the different processors till it arrives at the end of the route.

This example collects Date information but you can imagine to use this mechanism to check if your route processes the message according to SLA, ....

STEP 2 - Instantiate the bean in Camel Spring XML

<!-- Event Notifier -->
<bean id="auditEventNotifier" class="">

By adding this bean definition, Camel will automatically register it to the CamelContext created.

STEP 3 - Collect info into the log

18:10:46,060 | INFO | tp1238469515-285 | AuditEventNotifier | ? ? | 68 - org.apache.camel.camel-core - 2.6.0.fuse-00-00 | >>> Took 3 millis for the exchange on the route : mock-HTTP-Server
18:10:46,062 | INFO | tp2056154542-293 | AuditEventNotifier | ? ? | 68 - org.apache.camel.camel-core - 2.6.0.fuse-00-00 | >>> Took 25 millis to send to external system : Endpoint[http://localhost:9191/sis]
18:10:46,077 | INFO | tp2056154542-293 | AuditEventNotifier | ? ? | 68 - org.apache.camel.camel-core - 2.6.0.fuse-00-00 | >>> Took 103 millis for the exchange on the route : ws-to-sis