Download - Exploring Apache Camel
![Page 2: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/2.jpg)
Typical IoC application
Container Filters
MVC framework Views
Controller Controller Controller
Service Service Service
DAO DAO DAO
EXT
![Page 3: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/3.jpg)
Typical IoC application
This is your call stack: everyone's busy processing the request!
![Page 4: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/4.jpg)
Camel applicationConsumers(e.g. Jetty)
Camel
Filters Controllers Services
EXTDAOs Views
![Page 5: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/5.jpg)
Camel application
Everyone's doing it's workConveyor is provided by Camel
![Page 6: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/6.jpg)
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)
● ...
![Page 7: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/7.jpg)
EIP patterns
1 2 3?
C
A B
D
!
E
![Page 8: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/8.jpg)
Main camel primitivesContext
Component
Endpoint
Producer / Consumer
RouteBuilder
RouteDefinition
Route
Exchange
![Page 9: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/9.jpg)
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
![Page 10: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/10.jpg)
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>
![Page 11: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/11.jpg)
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>
![Page 12: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/12.jpg)
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”);
![Page 13: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/13.jpg)
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
![Page 14: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/14.jpg)
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
![Page 15: Exploring Apache Camel](https://reader036.vdocuments.us/reader036/viewer/2022081419/55968f4e1a28ab14438b459e/html5/thumbnails/15.jpg)
Questions? Suggestions?