question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support of Multiple @StreamListener methods on the same bound element

See original GitHub issue

Hi,

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:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:19 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
mbogoevicicommented, Jan 25, 2017

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:

  • if more than one condition matches, handlers will be executed serially in the same thread (for now, there’s no ordering convention) - at a first error, an exception will be thrown;
  • if more than one condition matches at runtime, and at least one of the handlers has a return type, an exception will be thrown - this is in order to prevent side-effects;
  • if no condition matches, we will issue a warning - it might be possible to consider adding a fallback mapping for a channel;
1reaction
garyrussellcommented, Dec 26, 2017

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.

spring.cloud.stream.kafka.binder.headers The list of custom headers that will be transported by the binder.

Default: empty.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found