Apache Camel Developer's Cookbook

For Apache Camel developers, this is the book you’ll always want to have handy. It’s stuffed full of great recipes that are designed for quick practical application. Expands your Apache Camel abilities immediately.

Apache Camel Developer's Cookbook

Cookbook
Scott Cranton, Jakub Korab

For Apache Camel developers, this is the book you’ll always want to have handy. It’s stuffed full of great recipes that are designed for quick practical application. Expands your Apache Camel abilities immediately.
$10.00
$49.99
RRP $29.99
RRP $49.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

+ Collection
Free Sample

Book Details

ISBN 139781782170303
Paperback424 pages

About This Book

  • 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.

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.

Table of Contents

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

What You Will Learn

Learn ways to structure your Camel projectsUnderstand common Enterprise Integration Pattern usageTransform your messagesUse Camel’s built-in testing frameworkExtend Camel to better interoperate with your existing codeLearn the strategies for Error HandlingUse Camel’s parallel processing and threading capabilitiesSecure your Camel integration routesUnderstand 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.

Authors

Table of Contents

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

Book Details

ISBN 139781782170303
Paperback424 pages
Read More