17 Clustering

 

This chapters covers

  • Clustered HTTP
  • Clustered Camel routes in active/passive and active/active modes
  • Clustered messaging with JMS and Kafka
  • Clustered caches
  • Clustered scheduling
  • Calling clustered services using the Service Call EIP

“How do I set up a highly available cluster with Camel?” That’s a simple question that doesn’t have a straightforward answer. You can ask the same question about a Java application server such as Apache Tomcat or WildFly and get a well-documented answer. Unlike Camel, these application servers are within a well-defined scope. They often support only a few protocols such as HTTP (Servlet) and messaging (JMS). Camel, on the other hand, speaks a lot more protocols, as you can tell by the many Camel components.

For example, a Camel application may expose a REST service and place its content into a database or filesystem. Or it may accept HL7 messages over TCP and route to a JMS broker. Or you may use Camel to stream from Kafka topics to a cloud service running on AWS. The answer to the question “How do I set up a highly available cluster with Camel?” depends on what you do with Camel.

To understand clustering support in Camel, we have to go back to the beginning. Camel was created in 2007 as a lightweight integration framework. Back then, Camel was just a set of JARs that you added to your classpath, so you could then run Camel in any JVM. Typically, you’d embed Camel into an existing application server or ESB.

17.1 Clustered HTTP

17.2 Clustered Camel routes

17.2.1 Active/passive mode

17.2.2 Active/active mode

17.2.3 Clustered active/passive mode using Hazelcast

17.2.4 Clustered active/passive mode using Consul

17.2.5 Clustered active/passive mode using ZooKeeper

17.3 Clustered JMS

17.3.1 Client-side clustering with JMS and ActiveMQ

17.4 Clustered Kafka

17.4.1 Kafka consumer offset

17.4.2 Crashing a JVM with a running Kafka consumer

17.5 Clustering caches

17.5.1 Clustered cache using Hazelcast

17.5.2 Clustered cache using JCache and Infinispan

17.6 Using clustered scheduling

17.6.1 Clustered scheduling using Quartz

17.7 Calling clustered services using the Service Call EIP

17.7.1 How the Service Call EIP works

17.7.2 Service Call using static service registry

17.7.3 Service Call with failover

17.7.4 Configuring Service Call EIP

17.7.5 Service Call URI templating

17.7.6 Service Call using Spring Boot Cloud and Consul

17.8 Summary and best practices