Aug 25th, 2010, 07:24 AM
Dynamic Router Support
I'm trying to determine how best to implement the Dynamic Router pattern using Spring Integration as described here.
The best I can see so far from searching the forums was to use one of the subclasses of AbstractChannelNameResolvingMessageRouter and implement a ChannelResolver.
Aug 25th, 2010, 10:19 PM
I would say it depends on the complexity of your routing requirement.
Dynamic router support was present in SI since its inception and was continuously improved.
We have use-case specific routers such as header-value-router or payload-type-router. Obviously they don't fall in the category of Dynamic Routers.
However, we also provide XML and annotation support for a generic router which is backed up by a POJO class that you have to implement (no need to extend anything from SI).
We also provide support for addressing Dynamic Router requirement s via Spring Expression Language (SpEL) where router element can specify 'expression' attribute which would return a channel or a collection of channels which essentially means that a Dynamic Router can be a content based router and recipient list router at the same time.
So maybe you should elaborate a little more about your specific use case and we'll take it from there.
Aug 26th, 2010, 06:15 AM
We want a dynamic payload type router where we send the rules for the dynamic routing to the router at runtime. For instance, at runtime send the router a new rule on the control channel saying:
"Here's a new payload type. Send all messages with a payload of this type of a specific channel (this channel would need to be created a runtime as well)."
Aug 26th, 2010, 09:26 AM
Great! We have exactly that. Have you looked at the ControlBus functionality provided in SI?
ControlBus support is a JMX wrapper which essentially allows you to define an adapter which is really a 'control channel' you are talking about. It will accept a control message mapping it to a managed operation of your choice (in this case the router bean would expose managed operation)
To make it simpler I've compiled a quick test case on which you can expend.
Its located here: https://src.springsource.org/svn/spr...on/jmx/config/
The file of interests are:
Aug 26th, 2010, 10:38 AM
Also, we just had a discussion on that and we are now going to expose addChannelMapping method on the payload-type-router and possibly header-value-router so these routers themselves become dynamic.
You can watch this JIRA
Nov 22nd, 2010, 06:54 PM
I haven't had a chance to try the new dynamic router support yet, but I've read the documentation for 2.0 and the JIRA ticket and would like to thank all contributors for their excellent support on meeting the community's needs.