Chapter 3. Routing to Your Code

In this chapter, we will cover the following recipes:

  • 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

Introduction

In this chapter, we will be looking at a number of ways of extending Camel with your own Java code, and invoking Camel routes from your Java code.

Camel was designed to make it very easy to work with existing Java code, and to make it straightforward to invoke Camel through your code without a lot of boilerplate code typically involved in using the underlying technologies such as JDBC, JMS, and others commonly used in integration.

This chapter will explore how your Java code can send and receive message data in the form of Java parameters and return types. It will discuss how your code can be reused to inform Camel routing decisions and message processing. We will cover how to go about creating re-useable Camel abstractions that make it even easier for your team to perform common message translations, and data type conversions, that are repeated throughout your integrations.

A number of Camel architectural concepts are used throughout this chapter. There is a broader overview of Camel concepts in the Preface. Full details can be found on the Apache Camel web site at http://camel.apache.org.

The code for this chapter is contained within the camel-cookbook-extend module of the examples.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.95.74