I have change a design like below I already have multiple camel sub routes which perform different actions, now my requirement was to align those sub routes in one flow for order fulfillment.
1- For every new product i knew which sub routes suppose to be execute and in which sequence, so i will save them in table and at start of application will get load in HashMap or CacheManager. 2- Now for my all products i have pre decided sequence of sub routes(Each sub route may have multiple integration with backend). Introduced new table product_flow table State Table: "StateID" "STATE", "NEXT_STATE", "STATE_RESULT", "CamelRoute" 100 1 , 2 , 1 , direct:initialValidation 101 1 , 10 , -1 , direct:sendNotification 103 2 , 10 , 1 , direct:placeOrder 104 10 , 0 , 1 , direct:sendNotification - any flow can be made active or inactive, sometime legacy nodes suppose to be bypass for any orders Product Flow "ProductId" StateID Status 2323 100 Active 2323 101 InActive 2424 100 Active 2424 104 Active from("jetty:http://127.0.0.1:8383/request") // Now below line will get flow from product_flow table .bean(OrderStateMachine.class, "loadOrderStateFlow(${body})") //Execute all state/action/subroute sequence in below loop on base of their status .loopDoWhile(simple("${body.NextState} == 0")) .bean(OrderStateMachine.class,"getNextState(${body})") .toD(simple("${body.State.CamelRoute}")) .end() .log("Request Processed");