1
votes

I am currently in progress of designing a lightweight messaging system. For this messaging system (a light hub), I have a requirement of a small routes based workflow. First, I do not want to use a workflow engine or a bpm engine as that would be an overkill for such a lightweight messaging solution.

My requirements are simple - I prefer to have a decider module / component which basically decides the next step / endpoint / component. The decider takes into account the curent status of the message, some predefined functional rules (maybe in a database) and some technical rules if needed. I was thinking of jms based communication between the different endpoints / components (these endpoints would be internal endpoints as part of the application) - this would allow loose coupling as well as would be more scaleable.

I was looking at camel and how and if it could help but I could not figure out a way where the next steps in a route would be defined by a central decider module / component.

I was also looking at the possibility of having multiple decider modules and chaining them if needed (if camel would be helpful there). Any idea how this could be implemented using camel or any other framework or just using java with spring?

1

1 Answers

0
votes

You could use a message header set by your decider and content based routing to control the message flow. For Example:

In your route that receives the message

...
.from(endpointreceivingmessage)
.process(decider)
.recipientList(simple("direct:${header.destinationRoute"));

In your decider processor

...
doProcess(Exchange exchange) throws Exception{
Message message = exchange.getIn(); 

//logic to determine next step
message.setHeader("destinationRoute", "DestinationRoute1"); 

exchange.setIn(message); 
}

Then you could have different routes for your next step, which could also be routes with processors to chain deciders.

An altenative to using recipientList would be to use choice:

.choice
 .when(simple("{header.destinationRoute} is 'DestinationRoute1'"))
  .to("direct:DestinationRoute1")
 .when(simple("{header.destinationRoute} is 'DestinationRoute2'"))
  .to("direct:DestinationRoute2")
  ...