Spring Integration MessageChannel ID

故事扮演 提交于 2019-12-25 02:43:42

问题


I need to dynamically assign messages to MessageChannels in my Spring Integration Context. I can do this by getting the MessageChannel bean from the context when I know the names of the MessageChannel I want.

What I need to do is programatically find the name/id of the message channel(s) that are set in my ChannelAdapter/Service.

However, the MessageChannel API does not have a getName() or getId() method associated with it.

Is there a way to find this piece of information?

Thanks in advance.


回答1:


Let's take look at this task from other side!

What is the reason to get deal with such low API like channels?

Why just don't use the Router pattern on the matter?

If I understand correctly, you want to have some dinamic routing, where you determine a destination channel by some Message property.

So it might be enough just use an expression router:

<int:router input-channel="input" expression="payload.theChannel"/>


来源:https://stackoverflow.com/questions/21459319/spring-integration-messagechannel-id

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