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

Decorate user-provided instances of ProducerRecord, instead of using them as a raw values #813

Merged
merged 7 commits into from
Aug 16, 2023

Conversation

guillermocalvo
Copy link
Contributor

While looking into #52, I realized Kafka producers can't handle ProducerRecord objects properly at the moment.

Since consumers can receive ConsumerRecord objects, I thought producers should be able to send ProducerRecord objects for the sake of symmetry.

This implementation works for both modes batch/single. Fields not populated by the user may be populated by the context as usual.

@KafkaClient
interface SingleProducer {
    @Topic("foo")
    String sendRecord(ProducerRecord<String, String> record);
}

@KafkaClient(batch = true)
interface BatchProducer {
    @Topic("foo")
    String sendRecords(List<ProducerRecord<String, String>> records);
}

@guillermocalvo guillermocalvo added the type: improvement A minor improvement to an existing feature label Aug 15, 2023
@guillermocalvo guillermocalvo self-assigned this Aug 15, 2023
@sdelamo sdelamo requested review from dstepanov and removed request for jeremyg484 August 16, 2023 07:45
`producerState.headersSupplier.get(ctx)` may return `null`
@sdelamo
Copy link
Contributor

sdelamo commented Aug 16, 2023

@guillermocalvo can you check CI failure?

'METHOD_DEF' has more than 1 empty lines before
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@guillermocalvo
Copy link
Contributor Author

@guillermocalvo can you check CI failure?

@sdelamo Done 4c6ead5 (it was checkstyle)

@sdelamo sdelamo merged commit d32bd51 into master Aug 16, 2023
@sdelamo sdelamo deleted the handle-producer-record-properly branch August 16, 2023 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants