Camel in Action, Second Edition
Claus Ibsen and Jonathan Anstey
  • MEAP began July 2015
  • Publication in Summer 2017 (estimated)
  • ISBN 9781617292934
  • 625 pages (estimated)
  • printed in black & white

Camel in Action, Second Edition is the most complete Camel book on the market. This updated tutorial is full of small examples showing how to work with the integration patterns. It starts with core concepts like sending, receiving, routing, and transforming data. It then shows you the entire lifecycle and goes in depth on how to test, deal with errors, scale, deploy, and monitor your app and even how to build custom tooling—details you can find only in the Camel code itself. Written by core developers of Camel and the authors of the first edition, this book distills their experience and practical insights so that you can tackle integration tasks like a pro.

Table of Contents detailed table of contents

Part 1: First Steps

1. Meeting Camel

1.1. Introducing Camel

1.1.1. What is Camel?

1.1.2. Why use Camel?

1.2. Getting started

1.2.1. Getting Camel

1.2.2. Your first Camel ride

1.3. Camel's message model

1.3.1. Message

1.3.2. Exchange

1.4. Camel's architecture

1.4.1. Architecture from 10,000 feet

1.4.2. Camel concepts

1.5. Your first Camel ride, revisited

1.6. Summary

2. Routing with Camel

2.1. Introducing Rider Auto Parts

2.2. Understanding endpoints

2.2.1. Consuming from an FTP endpoint

2.2.2. Sending to a JMS endpoint

2.3. Creating routes in Java

2.3.1. Using the RouteBuilder

2.3.2. The Java DSL

2.4. Defining routes in XML

2.4.1. Bean injection and Spring

2.4.2. The XML DSL

2.4.3. Using Camel and Spring

2.5. Endpoints revisited

2.5.1. Sending to dynamic endpoints

2.5.2. Using property placeholders in endpoint URIs

2.5.3. Using raw values in endpoint URIs

2.5.4. Referencing registry beans in endpoint URIs

2.6. Routing and EIPs

2.6.1. Using a content-based router

2.6.2. Using message filters

2.6.3. Using multicasting

2.6.4. Using recipient lists

2.6.5. Using the wireTap method

2.7. Summary and best practices

Part 2: Core Camel

3. Transforming data with Camel

3.1. Data transformation overview

3.1.1. Data transformation with Camel

3.2. Transforming data using EIPs and Java

3.2.1. Using the Message Translator EIP

3.2.2. Using the Content Enricher EIP

3.3. Transforming XML

3.3.1. Transforming XML with XSLT

3.3.2. Transforming XML with object marshaling

3.4. Transforming with data formats

3.4.1. Data formats provided with Camel

3.4.2. Using Camel's CSV data format

3.4.3. Using Camel's Bindy data format

3.4.4. Using Camel's JSON data format

3.4.5. Configuring Camel data formats

3.4.6. Writing your own data format

3.5. Transforming with templates

3.5.1. Using Apache Velocity

3.6. About Camel type converters

3.6.1. How the Camel type—converter mechanism works

3.6.2. Using Camel type converters

3.6.3. Writing your own type converter

3.7. Summary and best practices

4. Using beans with Camel

4.1. Using beans the hard way and the easy way

4.1.1. Invoking a bean from pure Java

4.1.2. Invoking a bean defined in XML DSL

4.1.3. Using beans the easy way

4.2. The Service Activator pattern

4.3. Camel's bean registries

4.3.1. JndiRegistry

4.3.2. SimpleRegistry

4.3.3. ApplicationContextRegistry

4.3.4. OsgiServiceRegistry and BlueprintContainerRegistry

4.3.5. CdiBeanRegistry

4.4. Selecting bean methods

4.4.1. How Camel selects bean methods

4.4.2. Camel's method-selection algorithm

4.4.3. Some method-selection examples

4.4.4. Potential method-selection problems

4.4.5. Method selection using type matching

4.5. Bean parameter binding

4.5.1. Binding with multiple parameters

4.5.2. Binding using built-in types

4.5.3. Binding using Camel annotations

4.5.4. Binding using Camel language annotations

4.5.5. Parameter binding using method name with signature

4.6. Using beans as predicates and expressions

4.6.1. Using beans as predicates in routes

4.6.2. Using beans as expressions in routes

4.7. Summary and best practices

5. Enterprise integration patterns

5.1. Introducing enterprise integration patterns

5.1.1. The Aggregator and Splitter EIPs

5.1.2. The Routing Slip and Dynamic Router EIPs

5.1.3. The Load Balancer EIP

5.2. The Aggregator EIP

5.2.1. Introducing the Aggregator EIP

5.2.2. Completion conditions for the Aggregator

5.2.3. Using persistence with the Aggregator

5.2.4. Using recovery with the Aggregator

5.3. The Splitter EIP

5.3.1. Using the Splitter

5.3.2. Using beans for splitting

5.3.3. Splitting big messages

5.3.4. Aggregating split messages

5.3.5. When errors occur during splitting

5.4. The Routing Slip EIP

5.4.1. Using the Routing Slip EIP

5.4.2. Using a bean to compute the routing slip header

5.4.3. Using an Expression as the routing slip

5.4.4. Using @RoutingSlip annotation

5.5. The Dynamic Router EIP

5.5.1. Using the Dynamic Router

5.5.2. Using the @DynamicRouter annotation

5.6. The Load Balancer EIP

5.6.1. Introducing the Load Balancer EIP

5.6.2. Load-balancing strategies

5.6.3. Using the failover load balancer

5.6.4. Using a custom load balancer

5.7. Summary and best practices

6. Using components

6.1. Overview of Camel components

6.1.1. Manually adding components

6.1.2. Autodiscovering components

6.2. Working with files (File and FTP components)

6.2.1. Reading and writing files with the File component

6.2.2. Accessing remote files with the FTP component

6.3. Asynchronous messaging (JMS component)

6.3.1. Sending and receiving messages

6.3.2. Request-reply messaging

6.3.3. Message mappings

6.4. Networking (Netty4 component)

6.4.1. Using Netty for network programming

6.4.2. Using custom codecs

6.5. Working with databases (JDBC and JPA components)

6.5.1. Accessing data with the JDBC component

6.5.2. Persisting objects with the JPA component

6.6. In-memory messaging (Direct, Direct-VM, SEDA, and VM components)

6.6.1. Synchronous messaging with the Direct and Direct-VM components

6.6.2. Asynchronous messaging with SEDA and VM

6.7. Automating tasks (Scheduler and Quartz2 components)

6.7.1. Using the Scheduler component

Part 3: Developing and testing

7. Microservices

8. Developing Camel projects

8.1. Managing projects with Maven

8.1.1. Using Camel Maven archetypes

8.1.2. Camel Maven dependencies

8.2. Using Camel in Eclipse

8.2.1. Starting a new Camel project

8.2.2. Debugging an issue with your new Camel project

8.3. Developing custom components

8.3.1. Setting up a new Camel component

8.3.2. Diving into the implementation

8.4. Generating components with the API component framework

8.4.1. Generating the skeleton API project

8.4.2. Configuring the camel-api-component-maven-plugin

8.4.3. Advanced configuration options

8.4.4. Implementing remaining functionality

8.5. Developing data formats

8.5.1. Generating the skeleton data format project

8.5.2. Writing the custom data format

8.6. Developing interceptors

8.6.1. Creating an InterceptStrategy

8.7. Summary and best practices

9. Testing

9.1. Introducing the Camel Test Kit

9.1.1. The Camel JUnit extensions

9.1.2. Using camel-test to test Java Camel routes

9.1.3. Unit testing an existing RouteBuilder class

9.2. Testing Camel with Spring, Blueprint, and CDI

9.2.1. Camel testing with Spring XML

9.2.2. Camel testing with Spring Java Config

9.2.3. Camel testing with Spring Boot

9.2.4. Camel testing with OSGi Blueprint XML

9.2.5. Camel testing with CDI

9.2.6. Camel testing with WildFly

9.3. Using the Mock component

9.3.1. Introducing the Mock component

9.3.2. Unit testing with the Mock component

9.3.3. Verifying that the correct message arrived

9.3.4. Using expressions with mocks

9.3.5. Testing the ordering of messages

9.3.6. Using mocks to simulate real components

9.4. Simulating errors

9.4.1. Simulating errors using a processor

9.4.2. Simulating errors using mocks

9.4.3. Simulating errors using interceptors

9.4.4. Using adviceWith to add interceptors to an existing route

9.4.5. Using adviceWith to manipulate routes for testing

9.4.6. Using weave with advice with to amend routes

9.5. Camel integration testing

9.5.1. Integration testing

9.5.2. Using NotifyBuilder

9.6. Using third party testing libraries

9.6.1. Using Arquillian to test Camel applications

9.6.2. Using Pax-Exam to test Camel applications

9.6.3. Using Citrus Framework to test Camel applications

9.6.4. Other Testing Libraries

9.7. Summary and best practices

Part 4: Going further with Camel

10. REST and Web Services

10.1. Restful services

10.1.1. The principle of an RESTful API

10.1.2. Using JAX-RS with REST services

10.1.3. Using Camel in an existing JAX-RS application

10.1.4. Using camel-reslet with REST services

10.1.5. Using camel-cxfrs with REST services

10.2. The Camel Rest DSL

10.2.1. A quick example of the Rest DSL

10.2.2. How the Rest DSL works

10.2.3. Supported components for the Rest DSL

10.2.4. Configuring Rest DSL

10.2.5. Using XML and JSon data formats with Rest DSL

10.3. API Documentation using Swagger

10.3.1. Using Swagger with JAX-RS Rest services

10.3.2. Using Swagger with Rest DSL

10.3.3. Documenting Rest DSL services

10.3.4. Documenting input, output and error codes

10.3.5. Configuring API documentation

10.3.6. Using CORS and Swagger web console

10.4. Web services

10.4.1. Configuring CXF

10.4.2. Using a contract-first approach

10.4.3. Using a code-first approach

10.5. Summary and best practices

11. Error handling

11.1. Understanding error handling

11.1.1. Where Camel’s error handling applies

11.2. Error handlers in Camel

11.2.1. The default error handler

11.2.2. The dead letter channel error handler

11.2.3. The transaction error handler

11.2.4. The no error handler

11.2.5. The logging error handler

11.2.6. Features of the error handlers

11.3. Using error handlers with redelivery

11.3.1. An error-handling use case

11.3.2. Using redelivery

11.3.3. Using the DefaultErrorHandler with redelivery

11.3.4. Error handlers and scopes

11.3.5. Reusing context scoped error handlers

11.3.6. Handling faults

11.4. Using exception policies

11.4.1. Understanding how onException catches exceptions

11.4.2. Understanding how onException works with redelivery

11.4.3. Understanding how onException can handle exceptions

11.4.4. Custom exception handling

11.4.5. New exception while handling exception

11.4.6. Ignoring exceptions

11.5. Other error-handling features

11.5.1. Using onWhen

11.5.2. Using onRedeliver

11.5.3. retryWhile

11.6. Summary and best practices

12. Transactions

12.1. Why use transactions?

12.1.1. The Rider Auto Parts partner integration application

12.1.2. Setting up the JMS broker and the database

12.1.3. The story of the lost message

12.2. Transaction basics

12.2.1. About Spring’s transaction support

12.2.2. Adding transactions

12.2.3. Testing transactions

12.3. The Transactional Client EIP

12.3.1. Using local transactions

12.3.2. Using global transactions

12.3.3. Returning a custom response when a transaction fails

12.4. Compensating for unsupported transactions

12.4.1. Introducing UnitOfWork

12.4.2. Using Synchronization callbacks

12.4.3. Using onCompletion

12.5. Idempotency

12.5.1. Idempotent Consumer EIP

12.5.2. Idempotent Repositories

12.5.3. Clustered idempotent repository

12.6. Summary and best practices

13. Parallel processing

13.1. Introducing concurrency

13.1.1. Running the example without concurrency

13.1.2. Using concurrency

13.2. Using thread pools

13.2.1. Understanding thread pools in Java

13.2.2. Camel thread pool profiles

13.2.3. Creating custom thread pools

13.2.4. Using ExecutorServiceStrategy

13.3. Parallel processing with EIPs

13.3.1. Using concurrency with the Threads EIP

13.3.2. Using concurrency with the Multicast EIP

13.3.3. Using concurrency with the Wire Tap EIP

13.4. The asynchronous routing engine

13.4.1. Hitting the scalability limit

13.4.2. Scalability in Camel

13.4.3. Components supporting asynchronous processing

13.4.4. Asynchronous API

13.4.5. Writing a custom asynchronous component

13.4.6. Potential issues when using an asynchronous component

13.4.7. Dangers with blocked threads

13.5. Summary and best practices

14. Securing Camel

14.1. Securing your configuration

14.1.1. Encrypting configuration

14.1.2. Decrypting configuration

14.2. Web service security

14.2.1. Authentication in web services

14.2.2. Authenticating web services using JAAS

14.3. Payload security

14.3.1. Digital signatures

14.3.2. Payload encryption

14.4. Transport security

14.5. Route authentication and authorization

===Summary and best practices

Part 5: Running and managing Camel

15. Running and Deploying Camel

16. Management and Monitoring

16.1. Monitoring Camel

16.1.1. Checking health at the network level

16.1.2. Checking health level at the JVM level

16.1.3. Checking health at the application level

16.2. Using JMX with Camel

16.2.1. Using JConsole to manage Camel

16.2.2. Using JConsole to remotely manage Camel

16.2.3. Using Jolokia to manage Camel

16.3. Tracking application activity

16.3.1. Using log files

16.3.2. Using core logs

16.3.3. Using custom logging

16.3.4. Using Tracer

16.3.5. Using notifications

16.4. Managing Camel applications

16.4.1. Managing Camel application lifecycles

16.4.2. Using Jolokia and hawtio to manage Camel lifecycles

16.4.3. Using Camel commands to manage Camel

16.4.4. Using controlbus to manage Camel

16.5. The Camel management API

16.5.1. Accessing the Camel management API using Java

16.5.2. Using Camel management API from within Camel

16.5.3. Performance Statistics

16.5.4. Management enable custom Camel components

16.5.5. Management enable custom Java beans

16.6. Summary and best practices

17. Clustering Camel

Part 6: Out in the wild

18. Camel in the cloud

19. Camel Tooling

19.1. Camel Editors

19.1.1. JBoss Tools for Apache Camel

19.1.2. fabric8 Camel editor

19.1.3. Camel Validation using Maven

19.2. Camel Catalog - The information goldmine

19.2.1. Developing custom tooling using the camel-catalog

19.2.2. Camel tooling with Karaf

19.3. hawtio - A web console for Camel and Java applications

19.3.1. Overview of hawtio functionality

19.3.2. Debugging Camel routes using hawtio

19.3.3. Building hawtio plugins

19.4. Summary and best practices


Appendix A: Setting up your IDE

Appendix B: The Simple Language

Appendix C: Using alternative DSLs

Appendix D: Contributing to Apache Camel

About the Technology

Apache Camel is a Java library that lets you implement the standard enterprise integration patterns in a few lines of code. With a concise but sophisticated DSL, you snap integration logic into your app, Lego-style, using Java, XML, CDI, Groovy, or Scala. Camel supports over 160 common transports including HTTP, REST, JDBC, JMS, Web Services, and SaaS connectors.

What's inside

  • Revised to reflect the most recent release of Camel
  • New chapters on security, clustering, cloud integration, docker, and kubernetes
  • How to build Camel microservices with Spring Boot, Vert.x, and standalone
  • Valuable examples in Java and XML
  • Explanations of complex patterns
  • Error handling, testing, deploying, managing, and running Camel
  • Accessible to beginners, useful to experts

About the reader

Readers should have basic Java skills.

About the authors

Claus Ibsen is a principal engineer working for Red Hat specializing in cloud and integration. He has worked on Apache Camel for the last seven years where he heads the project. He is also heavily involved with fabric8 and hawtio projects, especially with functionality that involves Camel. Claus lives in Sweden near Malmo with his wife and dog.

Jonathan Anstey is a principal engineer at Red Hat working on open source integration technologies. One of the many projects Jon contributes to is Apache Camel. When he is not hacking on open source he likes to spend time with his wife and two kids in Paradise, Newfoundland.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
  • MEAP combo $59.99 pBook + eBook
  • MEAP eBook $47.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks