Apache Camel Developer's Cookbook

Apache Camel Developer's Cookbook
eBook: $29.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $79.98    Print cover: $49.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters

A practical guide to using Apache Camel delivered in dozens of small, useful recipes Written in a Cookbook format that allows you to quickly look up the features you need, delivering the most important steps to perform with a brief follow-on explanation of what’s happening under the covers The recipes cover the full range of Apache Camel usage from creating initial integrations, transformations and routing, debugging, monitoring, security, and more

Book Details

Language : English
Paperback : 424 pages [ 235mm x 191mm ]
Release Date : December 2013
ISBN : 1782170308
ISBN 13 : 9781782170303
Author(s) : Scott Cranton, Jakub Korab
Topics and Technologies : All Books, Application Development, Cookbooks, Enterprise, Java

Table of Contents

Chapter 1: Structuring Routes
Chapter 2: Message Routing
Chapter 3: Routing to Your Code
Chapter 4: Transformation
Chapter 5: Splitting and Aggregating
Chapter 6: Parallel Processing
Chapter 7: Error Handling and Compensation
Chapter 8: Transactions and Idempotency
Chapter 9: Testing
Chapter 10: Monitoring and Debugging
Chapter 11: Security
Chapter 12: Web Services
  • Chapter 1: Structuring Routes
    • Introduction
    • Using Camel in a Java application
    • Embedding Camel in a Spring application
    • Using Camel components
    • Reusing routing logic by connecting routes
    • Asynchronously connecting routes
    • Spanning Camel contexts within a single Java process
    • Using external properties in Camel routes
    • Reusing endpoints
    • Reusing routing logic through template routes
    • Controlling route startup and shutdown
  • Chapter 2: Message Routing
    • Introduction
    • Content Based Routing
    • Filtering out unwanted messages
    • Wire Tap – sending a copy of the message elsewhere
    • Multicast – routing the same message to many endpoints
    • Recipient List – routing a message to a list of endpoints
    • Throttler – restricting the number of messages flowing to an endpoint
    • Request-response route sending a one-way message
    • One-way route waiting on a request-response endpoint
    • Dynamic Routing – making routing decisions at runtime
    • Load balancing across a number of endpoints
    • Routing Slip – routing a message to a fixed list of endpoints
  • Chapter 3: Routing to Your Code
    • Introduction
    • Routing messages directly to a Java method
    • Sending messages directly to a Camel endpoint
    • Using a Java method as a Predicate
    • Writing a custom Camel Processor
    • Mapping the message to method parameters
    • Writing a custom data marshaller
    • Writing a custom data type converter
  • Chapter 4: Transformation
    • Introduction
    • Transforming using a Simple Expression
    • Transforming inline with XQuery
    • Transforming with XSLT
    • Transforming from Java to XML with JAXB
    • Transforming from Java to JSON
    • Transforming from XML to JSON
    • Parsing comma-separated values (CSV)
    • Enriching your content with some help from other endpoints
    • Normalizing messages into a common XML format
  • Chapter 5: Splitting and Aggregating
    • Introduction
    • Splitting a message into fragments
    • Splitting XML messages
    • Processing split messages in parallel
    • Aggregating related messages
    • Aggregating with timeouts
    • Aggregating with intervals
    • Processing aggregated messages in parallel
    • Splitting a message, and processing and gathering responses
    • Splitting messages and re-aggregating them using different criteria
  • Chapter 6: Parallel Processing
    • Introduction
    • Increasing message consumption through multiple endpoint consumers
    • Spreading the load within a route using a set of threads
    • Routing a request asynchronously
    • Using custom thread pools
    • Using thread pool profiles
    • Working with asynchronous APIs
  • Chapter 7: Error Handling and Compensation
    • Introduction
    • Logging errors
    • Dead Letter Channel – handling errors later
    • Retrying an operation
    • Conditional retry
    • Customizing each redelivery attempt
    • Catching exceptions
    • Marking exceptions as handled
    • Fine-grained error handling using doTry…doCatch
    • Defining completion actions
    • Defining completion actions dynamically
  • Chapter 8: Transactions and Idempotency
    • Introduction
    • Preventing duplicate invocation of routing logic
    • Transactional file consumption
    • Using transactions with a database
    • Limiting the scope of a transaction
    • Rolling back a transaction
    • Using transactions with messaging
    • Idempotency inside transactions
    • Setting up XA transactions over multiple transactional resources
  • Chapter 9: Testing
    • Introduction
    • Testing routes defined in Java
    • Using mock endpoints to verify routing logic
    • Replying from mock endpoints
    • Testing routes defined in Spring
    • Testing routes defined in OSGi Blueprint
    • Auto-mocking of endpoints
    • Validating route behavior under heavy load
    • Unit testing processors and Bean Bindings
    • Testing routes with fixed endpoints using AOP
    • Testing routes with fixed endpoints using conditional events
  • Chapter 10: Monitoring and Debugging
    • Introduction
    • Logging meaningful steps within your route
    • Debugging using logging
    • Throughput logging
    • Enabling step-by-step tracing in code
    • Disabling JMX
    • Configuring JMX
    • Naming your routes to make it easier to monitor
    • Adding JMX attributes and operations
    • Monitoring other systems using the Camel JMX Component
    • Setting breakpoints in your routes
  • Chapter 11: Security
    • Introduction
    • Encrypting configuration properties
    • Digitally signing and verifying messages
    • Encrypting and decrypting a message
    • Encrypting all or parts of an XML message
    • Authentication and authorization using Spring Security
  • Chapter 12: Web Services
    • Introduction
    • Generating the service stubs from a WSDL
    • Invoking a remote web service from Camel
    • Implementing a web service with a Camel route
    • Providing multiple web service operations within a single route
    • Handling web service faults
    • Web service proxying

Scott Cranton

Scott Cranton is an open source software contributor and evangelist. He has been working with Apache Camel since the release of version 1.5 almost 5 years ago, and has over 20 years of commercial experience in middleware software as a developer, architect, and consultant. During his time at FuseSource, and now Red Hat, he has worked closely with many core committers for Apache Camel, ActiveMQ, ServiceMix, Karaf, and CXF. He has also helped many companies successfully create and deploy large and complex integration and messaging systems using Camel and other open source projects.

He divides his professional time between hacking code, delivering webinars on using Camel and open source, and helping companies to learn how to use Camel to solve their integration problems.

Jakub Korab

Jakub Korab is a consulting software engineer specializing in integration and messaging. With a formal background in software engineering and distributed systems, in the 14 years that he has worked in software across the telecoms, financial services, and banking industries, he naturally gravitated from web development towards systems integration. When he discovered Apache Camel, it became apparent to him how much time and effort it could have saved him in the past compared to writing bespoke integration code, and he has not looked back since.

Over the years, working as a consultant, he has helped dozens of clients build scalable, fault-tolerant, and performant systems integrations. He currently runs his own specialist consultancy, Ameliant, which focuses on systems integration and messaging using a stack of integration products from the Apache Software Foundation, of which Camel is a corner stone.

When not gluing systems together, you will find him spending time with his young family, and far too infrequently kitesurfing or skiing—neither of which he gets much chance to do in his adopted home, London.

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Apache Camel Developer's Cookbook +    Haskell Data Analysis Cookbook =
50% Off
the second eBook
Price for both: €33.25

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

Learn ways to structure your Camel projects Understand common Enterprise Integration Pattern usage Transform your messages Use Camel’s built-in testing framework Extend Camel to better interoperate with your existing code Learn the strategies for Error Handling Use Camel’s parallel processing and threading capabilities Secure your Camel integration routes Understand ACID Transaction processing within Camel

In Detail

Apache Camel is a de-facto standard for developing integrations in Java, and is based on well-understood Enterprise Integration Patterns. It is used within many commercial and open source integration products. Camel makes common integration tasks easy while still providing the developer with the means to customize the framework when the situation demands it. Tasks such as protocol mediation, message routing and transformation, and auditing are common usages of Camel. Apache Camel Developer's Cookbook provides hundreds of best practice tips for using Apache Camel in a format that helps you build your Camel projects. Each tip or recipe provides you with the most important steps to perform along with a summary of how it works, with references to further reading if you need more information. This book is intended to be a reliable information source that is quicker to use than an Internet search. Apache Camel Developer's Cookbook is a quick lookup guide that can also be read from cover to cover if you want to get a sense of the full power of Apache Camel. This book provides coverage of the full lifecycle of creating Apache Camel-based integration projects, including the structure of your Camel code and using the most common Enterprise Integration patterns. Patterns like Split/Join and Aggregation are covered in depth in this book. Throughout this book, you will be learning steps to transform your data. You will also learn how to perform unit and integration testing of your code using Camel's extensive testing framework, and also strategies for debugging and monitoring your code. Advanced topics like Error Handling, Parallel Processing, Transactions, and Security will also be covered in this book. This book provides you with practical tips on using Apache Camel based on years of hands-on experience from hundreds of integration projects.


This book is written in a Cookbook style with short recipes showing developers how to effectively implement EIP without breaking everything in the process. It is concise and to the point, and it helps developers get their data flowing between different components without the need to read through page upon page of theory, while also enabling the reader to learn how to create exciting new projects.

Who this book is for

Apache Camel Developer's Cookbook is intended for developers who have some familiarity with Apache Camel and who want a quick lookup reference to practical, proven tips on how to perform common tasks. Every recipe also includes a summary and reference pointers for more details that make it easy for you to get a deeper understanding of the Apache Camel capabilities that you will use day to day.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software