Apache Camel workshop at BarcelonaJUG in January 2014

Embed Size (px)

Citation preview

Workshop with Apache Camel

Claus Ibsen (@davsclaus)Principal Software Engineer, Red HatBarcelona JUG, january 2014

Agenda

Prerequisite

Try 1st Camel Example

Create new Camel projectDeploy our application to Apache Tomcat

Modify the application and use servlet/restlet

Install hawtio in Apache Tomcat

REST project with Apache CXF-RS

Fabric8 Demo

Pre-Requisite

Java 7

Maven 3.0.4 (or 3.1.1 most likely works now)

Eclipse, IDEA or NetBeans

Apache Camel 2.12.2

hawtio 1.2.2

Agenda

Prerequisite

Try 1st Camel Example

Create new Camel projectDeploy our application to Apache Tomcat

Modify the application and use servlet/restlet

Install hawtio in Apache Tomcat

(Create new Java Camel project)

(REST project with Apache CXF-RS)

REST project with Apache CXF-RS

Fabric8 Demo

Try 1st Apache Camel Example

Extract Apache Camel 2.12.2



Read the readme file and follow instructions


Mind a little bug in Camel 2.12.2 in the camel-stream component.
Is fixed in 2.12.1 and upcoming 2.12.3

Try 1st Apache Camel Example

Exercise 1


Make the example lower case instead!


Try 1st Apache Camel Example

Open example in IDEIDEA is just open project locate the pom.xml file

Try 1st Apache Camel Example

Open example in IDEEclipse File Import Existing Maven Project

Try 1st Apache Camel Example

Open example in IDESelect root folder

Try 1st Apache Camel Example

Edit the source code
src/main/resources/META-INF/
spring/camel-context.xml

Try 1st Apache Camel Example

Run the example from IDE






type the command which was listed in the readme

Try 1st Apache Camel Example

Run the example from IDE






type the command which was listed in the readme

Try 1st Apache Camel Example

The console is within the IDE






Try 1st Apache Camel Example

Run Maven in IDEA








I had to override maven home to 'fix this'





Agenda

Prerequisite

Try 1st Camel Example

Create new Camel projectDeploy our application to Apache Tomcat

Modify the application and use servlet/restlet

Install hawtio in Apache Tomcat

REST project with Apache CXF-RS

Fabric8 Demo

Create a new Camel project

Exercise 2


Create a new Camel Web project,
deployable in Apache Tomcat





Create a new Camel project

Use the Maven Archetypecamel-archetype-web

From the command line




Create a new Camel project

Or from IDEFile New Project... New Maven Project





Create a new Camel project

Or from IDEFilter by Camel and select camel-archetype-web





Create a new Camel project

Build the WAR


and deploy to Apache Tomcat



.. and start Tomcat


and see output on console




Create a new Camel project

Exercise 3


Modify application to listen on HTTP endpoint
and return a response message to client





Create a new Camel project

Add camel-servlet to Maven pom.xml


add servlet in WEB-INF/web.xml


Create a new Camel project

Add modify Camel route





build WAR and deploy to Tomcat by copying WAR



and try from browser

Create a new Camel project

Modify Camel route to add content based router







build WAR and deploy to Tomcat by copying WAR


and try from browser

Create a new Camel project

Exercise 4


Add Content Based Router and return
two different kind of reply messages





Create a new Camel project

Modify Camel route to add content based router







build WAR and deploy to Tomcat by copying WAR


and try from browser

Create a new Camel project

Exercise 5


Install hawtio and browse the route and
see runtime statistics

Try to update the route from hawtio

And try the debugger also.

Create a new Camel project

Download hawtio 1.2.2 default WARhttp://hawt.io/getstarted/index.html

Copy .war to Apache Tomcat and rename to hawtio.war



And access hawtio from web browserhttp://localhost:8080/hawtio




Create a new Camel project

Update route

Create a new Camel project

Debug route

Create a new Camel project

Exercise 6


Modify application to use restlet for simple
REST service as a Camel route

Create a new Camel project

Add camel-restlet to Maven pom.xml


and modify route



After deploy to Apache Tomcat try from browser

Create a new Camel project

Notice we are using port 8081 and not the servlet container from Apache Tomcat.

To do so see details athttp://camel.apache.org/restlet







Agenda

Prerequisite

Try 1st Camel Example

Create new Camel projectDeploy our application to Apache Tomcat

Modify the application and use servlet/restlet

Install hawtio in Apache Tomcat

REST project with Apache CXF-RS

Fabric8 Demo

REST project with Apache CXF-RS

REST using pure Apache CXF (no Camel)

Examplehttps://github.com/fabric8io/fabric8/tree/master/quickstarts/rest

Use JAX-RS annotations





REST project with Apache CXF-RS

Setup Apache CXF-RS serverEasier to do in Spring or OSGi Blueprint XML file







REST project with Apache CXF-RS

REST using pure camel-cxfrs (with Camel)Uses route(s) as input

Define API in java interface/class (as if JAX-RS)Either as interface

Or class implementation with no logic

Two binding modesDefault

Simple (in fact simpler and better)

Sorry at this I didn't have the time to implement
a Camel cxf-rs example for you

Agenda

Prerequisite

Try 1st Camel Example

Create new Camel projectDeploy our application to Apache Tomcat

Modify the application and use servlet/restlet

Install hawtio in Apache Tomcat

REST project with Apache CXF-RS

Fabric8 Demo

Fabric8 Demo

http://fabric8.io

Fabric8 Demo

Follow Getting Started Guide





Start Fabric8

http://fabric8.io

Fabric8 Demo

Create Fabric
(just use admin/admin for credentials)

open web browser - http://localhost:8181/

Fabric8 Demo

Switch to Fabric Perspective

Install the camel wiki example1. Click Configuration2. Navigate up the tree example camel3. Click wiki

Fabric8 Demo

4. Click the new button

5. Enter a container name6. And click Create Container

Container being created

Fabric8 Demo

7. Click container to see its details8. Click connect button to connect to it

9. And you see the logs of the container

Fabric8 Demo

7. Click container to see its details8. Click connect button to connect to it

9. And you see the logs of the container

Fabric8 Demo

10. Close the window and get back to the root container11. Click on wiki to be able to edit the Camel route

12. Click on camel.xml to
open Camel editor

Fabric8 Demo

13. The editor opens and you can
edit the Camel route14. Click apply and save to
save changes15. The container is updated.

Connect to the container to see
the updated changes.

Fabric8 Demo

Install and try the Loan Broker Example

See video how to do thathttp://vimeo.com/album/2635012/video/84674508 and there are more videos herehttp://vimeo.com/album/2635012

Click to edit the title text format

Click to edit the outline text format

PUBLIC PRESENTATION | CLAUS IBSEN

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level