'Run one Apache Camel route at a time
My product has an ingestion service written using Java which runs Apache Camel routes. There are multiple ingestion service instances running on different VMs. Ingestion service uses SQL Server 2016 database server. When each route is executed, it creates a job in the database and then each step of job manages the job status till it reaches the completion status.
Requirement is to ensure that Camel routes are executed one after another and no routes run in parallel (i.e., at the same time). How can this be accomplished?
One option is to use a home-grown solution where each route looks at whether there is a job in running status and proceed further only if there is none. This would require polling the database which does not seem to be a good solution.
Solution 1:[1]
When each route is executed, it creates a job in the database and then each step of job manages the job status till it reaches the completion status.
I would recommend a central service that manages the ingestion services using rest-api, jmx or something similar. It would provide jobs to these services and track their status. If the manager service needs persistence of its own it can use whatever like log files, json, embed sqlite database, nosql database etc. This would remove the need for ingestion services to know about other ingestion services or their state.
You can look at many CD/CI tools like Jetbrains TeamCity or Jenkins for reference on how they handle jobs with multiple agents/instances.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |