Routes in a Clustered Deployment
Two camel components distributed with Platform 6 that enable support for clustering are:
- camel-master: https://camel.apache.org/components/3.20.x/master-component.html
- camel-cluster: https://camel.apache.org/manual/clustering.html
A camel cluster service is implemented by Platform 6 to enable Hazelcast as a Cluster Service Implementation. This service is registered when the platform starts.
The service relies upon the Raft Consensus Algorithm used by Hazelcast, when configured as a cluster, and in particular tracks the election and re-election of a leader within the cluster.
Key Behaviours of Camel in a Platform 6 Cluster¶
1. Camel Context per Node¶
There are at least three nodes
in a Platform 6 cluster. Each cluster node has its own Camel Context
It is important that each node in a cluster has the same content in each of their context. For example, if a REST route is
deployed it is essential that all nodes are able to accept and process the HTTP request that makes up this route.
Essentially this means that all camel context in all cluster nodes are the same.
This does however present a problem if you have consumer routes like timers, schedules, ftp or file! In this case you can run into problems of multiple nodes reacting to time or file events for example.
To solve this it is recommended that you use the master
notation in the consumer url to ensure only one camel context in the cluster processes the consumer events.
Note
All nodes in a Platform 6 cluster share the same filesystem (NFS)
Note
There is always a master
node even when running as a single node instance, so it’s good practice to always use the master notation on such consumers
from("master:p6:timer:clustered?fixedRate=true&period=5000")
.routeId("clustered")
.log("Clustered route (timer) ...");
2. Start/Stop & Delete Context Operations¶
When using the route service UI and one of the Active Routes
action is used (start/stop/delete) all nodes in the cluster will receive the same action request.
This ensures the state of all camel context across all nodes is maintained.
3. Route Deployment Script Execution¶
When using the route service UI to execute a Groovy route deployment script, the script will be automatically executed on each node in the cluster; again ensuring all camel context are aligned.
This will be visible to a user in the Job List UI, when one job per cluster node will be visible.
Note
The general service Start
and service Stop
buttons available on all services will start/stop services in all nodes in the cluster maintaining consistent service state.
If you mark a route deployment script as Auto-start
it will be executed on each node in a cluster when the service starts.