Master Mind Master Mind - 2 months ago 57
Java Question

spring cloud stream kafka : Duplicate @StreamListener mapping for 'input'

I have a producer (

Source
) that writes messages to a Kafka output channel , that producer sends different type of objects. On the consumer side (
Sink
) I want to have multiple
@Streamlistener
methods on the same input channel each method with a different parameter type and currently it is not working I get
Duplicate @StreamListener mapping for 'input'
.

Here is my consumer code :

@StreamListener(Sink.INPUT)
public void on(PostUpvotedEvent event) {

}

@StreamListener(Sink.INPUT)
public void on(PostDownvotedEvent event) {

}


Is there a better solution to do that than having a single
@StreamListener
method which will test on the message type to choose which method to be called ?

Answer

Multiple @StreamListener methods on the same bound element are not supported now. It will be good to support this like in your case to register multiple subscribers on the inbound channel.

Please create a feature request here