title: Do I have to use @Payload spring annotation to read Kafka message
body: <p>Spring for Apache Kafka 2.8.4 under <a href="https://docs.spring.io/spring-kafka/reference/html/" rel="nofollow noreferrer">https://docs.spring.io/spring-kafka/reference/html</a> shows some of the listener methods with <code>@Payload</code> annotation next to the message and some do not. For example:</p>
  <pre class="lang-java prettyprint-override"><code>@KafkaListener(id = &quot;cat&quot;, topics = &quot;myTopic&quot;,
            containerFactory = &quot;kafkaManualAckListenerContainerFactory&quot;)
  public void listen(String data, Acknowledgment ack) {
      ...
      ack.acknowledge();
  }
  
  </code></pre>
  <p>and</p>
  <pre class="lang-java prettyprint-override"><code>@KafkaListener(id = &quot;qux&quot;, topicPattern = &quot;myTopic1&quot;)
  public void listen(@Payload String foo,
          @Header(name = KafkaHeaders.RECEIVED_MESSAGE_KEY, required = false) Integer key,
          @Header(KafkaHeaders.RECEIVED_PARTITION_ID) int partition,
          @Header(KafkaHeaders.RECEIVED_TOPIC) String topic,
          @Header(KafkaHeaders.RECEIVED_TIMESTAMP) long ts
          ) {
      ...
  }
  </code></pre>
  <p>What approach is correct? I am testing both and see no diference.</p>