Skip to content
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

Improve the implementation of the toMessage() function in the BatchMessagingMessageConverter: #3559

Merged
merged 4 commits into from
Oct 21, 2024

Conversation

esperar
Copy link
Contributor

@esperar esperar commented Oct 16, 2024

Improvement for BatchMessagingMessageConverter.toMessage()

While analyzing the toMessage() function of BatchMessagingMessageConverter, improvements were made. We have worked on improving it accordingly.

  1. Replace traditional loops with Java Stream API for processing collections. This enhances code conciseness and readability, allowing for functional-style operations on data.
private void processRecord(ConsumerRecord<?, ?> record, List<Object> payloads, List<Object> keys,
			List<String> topics, List<Integer> partitions, List<Long> offsets,
			List<String> timestampTypes, List<Long> timestamps, List<Map<String, Object>> convertedHeaders,
			List<Headers> natives, List<ConsumerRecord<?, ?>> raws, List<ConversionException> conversionFailures,
			Map<String, Object> rawHeaders, Type type) {
  // proceedRecord..
}
  1. Utilize Optional to handle potential null values more gracefully.
  2. Separate function that prints log once

I think The analysis of the toMessage() code is expected to become more convenient.

@sobychacko sobychacko added this to the 3.3.0-RC1 milestone Oct 21, 2024
@sobychacko sobychacko merged commit 6f79247 into spring-projects:main Oct 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants