How to persist dynamically created camel routes?
Asked Answered
T

1

6

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.

Taveda answered 18/2, 2015 at 13:22 Comment(2)
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.Calipash
@Calipash 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?Taveda
R
7

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.

Rollie answered 18/2, 2015 at 16:24 Comment(3)
Thank you, @boday that sounds like a good way to go. Another approach would be to store a meta data file in each of the directories (all are file endpoints) containing the current status of the corresponding route. Then it would be possible to create a new directory, store the status file in it and automatically create/configure an new route or re-create them after restarting the context.Taveda
This is interesting to me so I have upvoted it. Thanks for the interesting question, MichaelCalipash
There is some example of your solution?Resonance

© 2022 - 2024 — McMap. All rights reserved.