0
votes

My question may be a repeating one.. but I was unable to find answer for this..

Our team is evaluating Spring Integration to replace the Message Broker flows.. Meanwhile I am writing the integration for consuming two different web service where in a single configuration I have defined separate channels for each web service outbound-gateway. I figured out to use chaining to reduce the channel definition between the endpoints & it works well.

All i need to ask is, is it possible to share the same channel between various web service outbound-gateway? Can I define only one channel where 2 web service outbound will be listening for messages?

If yes then how will SI identify that message-1 on channel-1 is for gateway-1 and message-2 on channel-1 is for gateway-2 and so on? Is it necessary to define a unique channel for each web service outbound gateway?

-Thanks MS

1

1 Answers

1
votes

Yes, generally, each gateway needs its own channel.

However...

If you want to send the SAME message to both gateways, you can use a <publish-subscribe-channel/>.

If you want to "round robin" (load balance) across multiple instances of the same service then, yes, you simply subscribe each gateway to the same channel and they will alternate.

You could use a custom load balancing strategy to decide which gateway will get a message but it's probably better to simply use a router and have each gateway have its own channel.

It really depends on your use case, but there are lots of options.

However, don't fall into the trap of trying to eliminate channels everywhere - that's one of the compelling features of Spring Integration - the ability to change channel types/features without rewiring your entire application.