Skip to content

The DefaultHandler resolves an incorrect value for the parameter annotated with @Header. #3880

@chickenchickenlove

Description

@chickenchickenlove

In what version(s) of Spring for Apache Kafka are you seeing this issue?

Current, main branch.

Describe the bug

@KafkaListener(topics = "myTopic")
class MyListener {

  @KafkaHandler(isDefault = true)
  public void handleValue(@Header("kafka_receivedTopic") String topic, String message) { 
   // Anything.
  }
 }

public static void main() {
  String myMessage = "msg";
  template.send("myTopic", myMessage);
}

If we have listener with DefaultHandler,
the topic value is always same with message.
it means that equation below is true.

topic.equals(message)

To Reproduce

You can refer to code snippet MyListener.

Expected behavior

  • As-Is
    • Either topic or message are msg.
  • To-Be
    • The value of topic should be 'myTopic'.
    • The value of message should be 'msg'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions