0

we have a scenario where message routing should happen based on the message content and different conditions. we will be storing the conditions in DB, conditions would configured at runtime by different app , we are planning keep this routing conditions in cache which routing app can access.

over all routing application job is figure out the next step (queue) based on message and conditions and put the message to correct queue so that related application pick the msg and process it.

Is there simple way to implement this scenario without using apache camel etc. conditions are simple equal, not equal etc inspecting the XML message.

kantesh
  • 61
  • 1
  • 6
  • Please have a look at this - https://camel.apache.org/components/latest/eips/dynamicRouter-eip.html – Venkat Jul 04 '20 at 16:32

2 Answers2

0

You can do these kinds of dynamic routing with the Recipient List EIP of Camel. If the simple conditions like a header value etc are not sufficient, you can use a Java Bean method as Recipient List.

In this method you can access all parts of the message and do whatever you want. If you found out where the message must be sent to, simply return the Camel endpoint URI. For example activemq:queue:myQueue.

The recipient list can also send the (same) message to multiple endpoints if this is a requirement.

burki
  • 6,741
  • 1
  • 15
  • 31
0

Spring Integration provides a Router EIP implementation where you can specify your custom logic via POJO method invocation and decide to which output channel to send the message: https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#messaging-routing-chapter

That's why the MessageChannel is one of the fist class citizen in the framework: your business logic is not tied with the routing logic and you may make any complex flows on each channel sub-flow not affecting anything else in the application.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118