Chapter 2. Routing with Camel


This chapter covers

  • An overview of routing
  • Introducing the Rider Auto Parts scenario
  • The basics of FTP and JMS endpoints
  • Creating routes using the Java DSL
  • Configuring routes from Spring
  • Routing using enterprise integration patterns (EIPs)

One of the most important features of Camel is routing; without it, Camel would essentially be a library of transport connectors. In this chapter, we’ll dive into routing with Camel.

Routing happens in many aspects of everyday life. When you mail a letter, for instance, it may be routed through several cities before reaching its final address. An email you send will be routed through many different computer network systems before reaching its final destination. In all cases, the router’s function is to selectively move the message forward.

In the context of enterprise messaging systems, routing is the process by which a message is taken from an input queue and, based on a set of conditions, sent to one of several output queues, as shown in figure 2.1. This effectively means that the input and output queues are unaware of the conditions in between them. The conditional logic is decoupled from the message consumer and producer.

Figure 2.1. A message router consumes messages from an input channel and, depending on a set of conditions, sends the message to one of a set of output channels.

2.1. Introducing Rider Auto Parts

2.2. Understanding endpoints

2.3. Creating routes in Java

2.4. Creating routes with Spring

2.5. Routing and EIPs

2.6. Summary and best practices