For your first point, when you say that you save the route names in a
table, do you mean something like a camel Routing Slip
<http://camel.apache.org/routing-slip.html>, or a data structure of your
own? Consider using the Dynamic Router
<http://camel.apache.org/dynamic-router.html> feature if you haven't looked
at it already.  If you must use a state table, then your dynamic router can
use it to compute the next step on the fly.  I would definitely recommend
using the routing slip or dynamic router pattern in conjunction with a
state machine implementation like StatefulJ.

Another option to consider is to programmatically determine the routing at
order creation time, based on things like product and the systems that are
involved.  Create a routing slip as described in my first link, above, and
send the message across the route.  When the order is at a state where it
cannot automatically progress, or in the event of an error, you can persist
the contents of the remainder of this routing slip in a datastore (like
mongodb, etc) and then retrieve it and resume routing when the order is
ready to transition to the next state.

Either option (routing slip or dynamic router) should keep everything nice
and clean.  Then the transactional stuff I mentioned in a previous comment
would be a really good idea as well.  The point that I am still not quite
clear on is the high number of states that you mentioned.  Why are there so
many?

Thanks,
Steve

On Thu, Jan 11, 2018 at 5:23 PM, Imran Raza Khan <imranrazak...@gmail.com>
wrote:

> 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");
>

Reply via email to