Skip to content

GH-3067: Spring Kafka support multiple headers with same key.#3874

Merged
artembilan merged 20 commits intospring-projects:mainfrom
chickenchickenlove:GH-3067
May 12, 2025
Merged

GH-3067: Spring Kafka support multiple headers with same key.#3874
artembilan merged 20 commits intospring-projects:mainfrom
chickenchickenlove:GH-3067

Conversation

@chickenchickenlove
Copy link
Copy Markdown
Contributor

@chickenchickenlove chickenchickenlove commented Apr 27, 2025

I know that there is an existing PR(#3101) related to this issue, but it seems to have been suspended for long time.
Therefore, I created a new PR to address it.
If you are planning to maintain the existing one, I am happy to close mine.

I approached the problem differently from the existing PR and proposed an alternative solution.
For backward compatibility, user can configure MultiValueKafkaHeaderMapper to KafkaListenerContainerFactory.
For example,

ConcurrentKafkaListenerContainerFactory<Integer, String> factory =
					new ConcurrentKafkaListenerContainerFactory<>();

MultiValueKafkaHeaderMapper headerMapper = new MultiValueKafkaHeaderMapper();

// Create new header mapper.
headerMapper.addSingleValueHeader(SINGLE_VALUE_HEADER);
MessagingMessageConverter converter = new MessagingMessageConverter(headerMapper);

// Set header mapper.
factory.setConsumerFactory(consumerFactory());

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spring Kafka does not allow multiple headers with same key

3 participants