These methods are exposed as operations over JMX, and available via the <control-bus/>...
Code:
<int:control-bus input-channel="control"/>
<int:router id="hvr2" input-channel="x" ref="controlledHVR"/>
<bean id="controlledHVR" class="org.springframework.integration.router.HeaderValueRouter">
<constructor-arg value="routing.header" />
<property name="channelMappings" ref="initialMap" />
</bean>
<util:map id="initialMap">
<entry key="foo" value="bar"/>
</util:map>
Just send a message containing "@controlledHVR.setChannelMapping('baz', 'qux')" to the control channel.
Or, you can use raw JMX...
Code:
<context:mbean-server />
<int-jmx:mbean-export default-domain="test.domain" />
<int:header-value-router id="hvr" input-channel="x" header-name="routing.header">
<int:mapping value="foo" channel="y"/>
</int:header-value-router>
Code:
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
// verify you only have one, or figure out which one you want
MBeanServer server = servers.get(0);
server.invoke(new ObjectName(
"test.domain:type=HeaderValueRouter,name=hvr"),
"setChannelMapping", new Object[] { "baz", "quz" },
new String[] { "java.lang.String", "java.lang.String" });
Note that you can't use the <control-bus/> at the same time as the MBean exporter - this might be a bug; I need to think about it some more.
Also, we have an open JIRA to expose a single call to replace the entire channel mappings in an atomic update over JMX...
https://jira.springsource.org/browse/INT-2352
Of course, with the first configuration above, you can inject the HVR into your own class and invoke its methods directly.