Skip to content

The listener info header is not added when using a batch listener #2249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
frosiere opened this issue Apr 29, 2022 · 2 comments · Fixed by #2257
Closed

The listener info header is not added when using a batch listener #2249

frosiere opened this issue Apr 29, 2022 · 2 comments · Fixed by #2257

Comments

@frosiere
Copy link
Contributor

The issue #2134 introduced a way to set arbitrary information using the info property of the KafkaListener annotation. This info is then added as a header on the ConsumerRecord.

When using a batch listener, this header is not added on the records.

Based on the documentation (https://docs.spring.io/spring-kafka/docs/current/reference/html/#li-header), the header is only available in the record interceptor but it would certainly make sense to also have it in when using a batch interceptor.

The internal headers are currently added in KafkaMessageListenerContainer#internalHeaders but this method is only called for single record listeners (see KafkaMessageListenerContainer#checkEarlyIntercept).

Batches are handled in KafkaMessageListenerContainer#invokeBatchListener. So, the interceptor could be called after having iterated on the list of records to allow adding the info header.

@artembilan
Copy link
Member

@garyrussell garyrussell added this to the 3.0.0-M4 milestone May 2, 2022
@garyrussell garyrussell self-assigned this May 4, 2022
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue May 4, 2022
artembilan pushed a commit that referenced this issue May 5, 2022
Resolves #2249

* Single String parameter for batch listeners.

* Polish docs for an empty batch.

**cherry-pick to 2.9.x, 2.8.x**
artembilan pushed a commit that referenced this issue May 5, 2022
Resolves #2249

* Single String parameter for batch listeners.

* Polish docs for an empty batch.

**cherry-pick to 2.9.x, 2.8.x**
artembilan pushed a commit that referenced this issue May 5, 2022
Resolves #2249

* Single String parameter for batch listeners.

* Polish docs for an empty batch.

**cherry-pick to 2.9.x, 2.8.x**
@frosiere
Copy link
Contributor Author

frosiere commented May 6, 2022

Thanks a lot for the very quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants