Stephen McConnell
Stephen McConnell

Reputation: 64

Spring Integration MessageChannel ID

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.

Upvotes: 0

Views: 577

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121570

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"/>

Upvotes: 1

Related Questions