Question

I want to build a scheme with several outbound gateways, that could be added in runtime (lets say it starts with 2 gateways but have ability to add 3rd-4th in runtime). I want to have http-outbound-gateways for their functionality but wanna build their instances in runtime. The problem is in registering channels subscribed to these gateways in spring context. Atm I have 3 desicions and cant choose right one.

  1. Register newely created channels to application context with registerBeanDefinition("<my id>", definition) or something similar. Not happy with this desicion cause would prefer not to have such rough access to already built context.

  2. Have predefined list of channels, and limit insertion of new outbound gateways with number of this predefined channels. Variant suits me since there's only few gateways planned and it seems quite safe for me, though not very neat.

  3. Searching for solution, I found org.springframework.integration.support.channel.BeanFactoryChannelResolver with org.springframework.integration.support.channel.HeaderChannelRegistry that seems suitable for me to use with prototyped channel bean. (map names that i have to refs i require). However since org.springframework.integration.support.channel.BeanFactoryChannelResolver doesnt have public setter for this registry, im not sure i can use it safely, though i consider using own ChannelResolver for this needs.

What is the right way to solve this?

Was it helpful?

Solution

See the dynamic-ftp sample application. It adds ftp outbound adapters using a child application context for each.

In effect, a dynamic router routes to the input channel for each adapter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top