I design pseudo implementation of state machine in Apache camel like below,
Please comment/suggest to improve design



Table Contains State: (Would be populate in HashMap at start of Application)

"STATE", "NEXT_STATE", "STATE_RESULT",       "CamelRoute"

     1       ,           2           ,    1
            ,          direct:initialValidation

     1       ,          10          ,   -1                       ,
direct:sendNotification

     2       ,          10          ,    1                       ,
direct:placeOrder

     .       ,             .           ,     .                       ,
                   .

    .       ,             .           ,     .                       ,
                    .

   10      ,            0          ,     1                       ,
direct:sendNotification





Route:

from("jetty:http://127.0.0.1:8383/request";)

.log("Received a request")

.unmarshal(jaxb)

.bean(OrderStateMachine.class, "loadOrderStateFlow(${body})")

                .loopDoWhile(simple("${body.NextState} == 0"))

                                .bean(OrderStateMachine.class,
"getNextState(${body})")

                                .toD(simple("${body.NextState}"))

                .end()

.log("Request Processed");



Regards

Reply via email to