Support of Multiple @StreamListener methods on the same bound element
See original GitHub issueHi,
I have a case where I want to have multiple @StreamLinstner methods that are listening on the same bound element. The methods signature are different depending the type of message being received. Here is the example:
@StreamListener(Sink.INPUT)
public void on(PostUpvotedEvent event) {
}
@StreamListener(Sink.INPUT)
public void on(PostDownvotedEvent event) {
}
Currently, this is not supported and there is an exception with this message Duplicate @StreamListener mapping for 'input'.
I think it will be convenient to have this feature. Thanks
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:19 (12 by maintainers)
Top Results From Across the Web
java - spring cloud stream kafka : Duplicate @StreamListener ...
Multiple @StreamListener methods on the same bound element are not supported now. It will be good to support this like in your case...
Read more >Spring Cloud Stream Reference Guide
If there are multiple consumer instances bound using the same group name, then messages will be load-balanced across those consumer instances so that...
Read more >Duplicate @StreamListener mapping for 'input'-Springboot
Multiple @StreamListener methods on the same bound element are not supported now. It will be good to support this like in your case...
Read more >Introduction to Spring Cloud Stream - Baeldung
Channel — represents the communication pipe between messaging-middleware and the application; StreamListeners — message-handling methods in ...
Read more >Steeltoe Stream Reference
Steeltoe Stream supports dispatching messages to multiple handler methods ... If there are multiple consumer instances bound with the same group name, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Chatting a bit more with @dturanski, here are couple of further refinements to the proposal in cases when more than one condition is met for an incoming message:
It’s best to not add comments to closed issues, but open a new issue if you find a problem. Questions should be submitted on Stack Overflow or in gitter.
If you are using the kafka11 binder, headers are supported natively (added to the 0.11.x.x client and above including 1.0.0).
If you are using 1.3.0 or earlier versions of the binder (with the default kafka 0.10.x.x client) you need to tell the binder which header(s) should be transported. See Kafka Binder Properties in the documentation.