Typical IoC application
Container Filters
MVC framework Views
Controller Controller Controller
Service Service Service
DAO DAO DAO
EXT
Typical IoC application
This is your call stack: everyone's busy processing the request!
Camel applicationConsumers(e.g. Jetty)
Camel
Filters Controllers Services
EXTDAOs Views
Camel application
Everyone's doing it's workConveyor is provided by Camel
Some camel ext connectors● HTTP (Jetty, Client v3, Client v4, GAE, Servlet)
● MQ (AMQP, ActiveMQ, ZeroMQ, MQTT, SQS)
● DB (JPA, DynamoDB, SimpleDB, CouchDB, Hazelcast, Hbase, iBatis, JDBC, MongDB, Zookeeper, Hibernate)
● BLOB (File, HDFS, FTP, SCP, S3)
● RPC (CXF, RMI, Avro, SSH, JGroups)
● ...
EIP patterns
1 2 3?
C
A B
D
!
E
Main camel primitivesContext
Component
Endpoint
Producer / Consumer
RouteBuilder
RouteDefinition
Route
Exchange
Camel RegistryCamel supports components lookup with plugable mechanism named Registry.
Next registry types are supported out of box:● Simple — simple map-based ● JNDI — looks up objects in JNDI● ApplicationContext — looks up objects in Spring
This means that Camel easily intergrates with Spring for complex components assembling and configuration
Camel DSLsCamel routes can be expressed in next DSLs:
✔ Java / Groovy /Scala / Kotlin (WiP)✔ Spring XML / Blueprint XML✔ Annotations
Java examplefrom("test-jms:queue:test.queue")
.to("file://test");
Spring example<route> <from uri="test-jms:queue:test.queue"/> <to uri="file://test"/></route>
Adding own codeYou can write your own component / endpoint / consumer / producer
➔ Good when you are developing reusable component, need advanced features or making a consumer
Or simply call a POJO➔ When you simply need some logic
public class MyService { Answer process(Request arg) { ... }}
<bean id=”myService” class=”MyService”/><route> <from uri="servlet:callMyService"/> <unmarshall><jaxb .../></unmarshall> <to uri="bean:myService"/> <marshall><jaxb .../></marshall></route>
Reusing routes➔ You can use
“direct” component to call routes from another routes or your code.
➔ Use direct-vm to call routes from another context
<route> <from uri="direct:save"/> <to uri="file://test"/></route>
<route> ... <to uri="direct:save"/> ...</route>
@EndpointInject(uri = "direct:save") ProducerTemplate saveRoute;...SaveRoute.sendBody(“testBody”);
Handling exceptionsYou can define exception handling directly in camel routes. It can:
● Use different strategies based on exception class
● Perform automatic retries (redeliveries)● Call “exceptional” route● Define “continue” or “stop route” handlers
Monitoring your routesCamel automatically gathers statistics on your routes and provides it with JMX.
Statistics is:● Enabled by default● Provides detailed statistics up to single endpoint
level● Has timings and success/failure counters● Can be retrieved as a single XML file for the route
or the whole context
Questions? Suggestions?