6
votes

I am creating routes dynamically using a custom processor listening to a "control route". It creates the routes depending on the message content which is sent to the control route. It is used to dynamically create FTP/file endpoints by another system.

I'm using Camel as blueprint bundle inside ServiceMix and Hawtio to control the state of the routes (e.g. suspend them).

It works fine but (logically) these routes are not recognized if the camel context is restarted because there is no persistent route configuration.

Is there some best practice on how to persist the routes?

I'm thinking of re-creating the routes from reading the directory structure of the file endpoints or using a database to persist the routes and their state.

1
Is there a way you can statically create the routes, and manage the routing via some properties and recipientList style links? It's an interesting problem you have here. - vikingsteve
@vikingsteve the setup of the routes is initiated from another system which manages users and their data interfaces to the system. A user and his way of sending data is created there. If it is set to FTP, the route should be created dynamically and the ftp user and his upload directories are created by a script (all done in the processor). I think a recipient list would also be lost after restarting the context, am I right? - Michael Brohl

1 Answers

7
votes

we had the same scenario and chose to use a database table to store the meta data about each route and reconstruct the routes on startup...this is pretty easy assuming your routes are fairly static in nature.

we also considered adding the route as Spring DSL/XML to a file and loading it on startup. But we chose the database approach because we also needed to expose this meta data to a UI to manage the routing configs, etc. Then simply listen for changes to the config and remove/re-add routes as needed, etc.