Type: New Feature
Resolution: Won't Fix
Affects Version/s: None
Fix Version/s: None
When one needs to factorize some chain of endpoints, it would be useful to define a common chain (with or without input and output channels) and be able to call it from anywhere by defining (or overriding) the input and output channels.
For example, we might want to call frequently the following <chain>:
but for different input and – especially! – output channels.
As discussed on the forum,
- The possibility to have a different output-channel is necessary, as, in the same context, we might want to have two flows invoking the same chain without interferring with each other.
- The router is not an option for such a usecase :
Indeed, the <chain> being configured in a separated file (and potentially saved in a different jar put at disposal of other applications), it is not aware of its "clients" and we don't want to modify the router (and thus the common jar) every time a new client wants to invoke the <chain>.
- Setting the replyChannel header before calling the <chain> has also some drawbacks, such as:
- The common <chain> might also want to set the replyChannel header for a similar reason, which would then override the value set by the "client".
- The common <chain> could not be called within another <chain> as the output-channels are not explicitely defined.
- Not easily readable for an external reader.
Here's a suggestion which looks easy to understand for an external reader, quite straightforward to try for a Spring developper used to reusing beans, and which doesn't have all the previously mentionned drawbacks:
Maybe "ref" is not the best attribute name as it is often used for POJOs in Spring Integration, but it is often used in this context in Spring and a POJO wouldn't probably make sense for a chain.