Runtime configurable dynamic routing in spring integration

馋奶兔 提交于 2021-01-24 04:51:27

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/23248987/runtime-configurable-dynamic-routing-in-spring-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!