spring-cloud / spring-cloud-stream

Framework for building Event-Driven Microservices
http://cloud.spring.io/spring-cloud-stream
Apache License 2.0
969 stars 595 forks source link

Ability to re-use the same function in multiple streams #2950

Closed sobychacko closed 4 weeks ago

sobychacko commented 1 month ago

Currently, if you want to reuse a function that contains the business logic in multiple streams in the same app, you need to use function composition by providing a pass-through function on the front. This is boilerplate and unnecessary, as the framework should support this use case.

More details: https://stackoverflow.com/questions/78395621/spring-cloud-stream-binder-several-bindings-with-same-processor

olegz commented 4 weeks ago

I just thought about it. . . How would it work? Function is bound to a destination(s). . . let's call it a binding function and as @sobychacko had suggested you can create such binding function as pass-thru and compose it with the "real" function. Or simply make a call back to a "real" function from a pass thru function. Perhaps not ideal, but reasonable workaround. . . for now.

OR

What you are asking is to create an explicit destination binding and a mechanism to map specific function to it. This way single function (or composition) could be mapped to multiple bindings. Is that correct?