Skip to content

Conversation

kjswaruph
Copy link
Contributor

Summary

Add Crac support for kafka module of powertools.

Changes

Please provide a summary of what's being changed

  • Add powertools-common dependency, maven test profile and classesloaded.txt for preloading
  • Add Crac dependency and update PowertoolsSerializer to register as Crac Resource
  • Add tests in PowertoolsSerializerTest to assert beforeCheckpoint and afterRestore hooks do not throw exception

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: #1999


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@svozza
Copy link
Collaborator

svozza commented Sep 16, 2025

Hi @kjswaruph. Thank you for the PR! I have assigned the PR to you and we will begin reviewing it and giving feedback soon.

@phipag
Copy link
Contributor

phipag commented Sep 25, 2025

Hey @kjswaruph, thanks for opening this PR 🚀 I will review it in depth next week.

In the meantime, let's try to increase the priming to the other serializers beyond JSON. I think we can leverage Avro GenericRecord here with a simple hardcoded String schema. See these docs: https://avro.apache.org/docs/1.12.0/getting-started-java/. And we can generate a valid Kafka event JSON similar to this (from unit tests of Kafka module): https://github.com/aws-powertools/powertools-lambda-java/blob/main/powertools-kafka/src/test/java/software/amazon/lambda/powertools/kafka/PowertoolsSerializerTest.java#L271-L273. Instead of the generated TestProduct we would use a simple GenericRecord. I would be curious to see if this works, do you think you can add this? Let me know if you need some clarification.

Let's ignore Protobuf for now since it doesn't support something similar to GenericRecords and I don't want to hook up this library module with a whole Protobuf generation toolchain just for Snapstart priming.

@phipag phipag moved this to Working on it in Powertools for AWS Lambda (Java) Sep 29, 2025
@phipag
Copy link
Contributor

phipag commented Oct 2, 2025

Hey @kjswaruph, do you already know when you can work on this? Let me know if you need any help!

@kjswaruph
Copy link
Contributor Author

Hi @phipag, sorry for responding late. I’ll update the PR with the Avro GenericRecord as recommended and aim to finish it by this weekend. If I encounter any issues or need clarification, I’ll reach out. Thanks again for your feedback!

@kjswaruph kjswaruph force-pushed the feat/add-crac-priming-to-kafka-module branch from 2355544 to 46f66e3 Compare October 4, 2025 10:49
@kjswaruph
Copy link
Contributor Author

@phipag I added the avro priming. Please review and tell me if any changes are required.

Copy link
Contributor

@phipag phipag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kjswaruph,

thanks again for updating the PR. I did an in-depth review of the code and tested the priming in my AWS account. I believe the Avro priming does not work because we need a type of SpecificRecordBase and not GenericRecord.

Due to the complexity of this (and increase in bundle size as a result) I am in favor of removing the Avro priming again and just keeping the JSON priming that you already included.

The rest looks good to me!

@github-project-automation github-project-automation bot moved this from Working on it to Pending review in Powertools for AWS Lambda (Java) Oct 14, 2025
@kjswaruph kjswaruph closed this Oct 16, 2025
@kjswaruph kjswaruph force-pushed the feat/add-crac-priming-to-kafka-module branch from a9bb498 to a91c090 Compare October 16, 2025 05:36
- Add  maven test profile and classesloaded.txt for preloading
- Add Crac dependency and update PowertoolsSerializer to register as Crac Resource
- Add tests in PowertoolsSerializerTest to assert beforeCheckpoint and afterRestore hooks do not throw exception
@kjswaruph kjswaruph reopened this Oct 16, 2025
@github-project-automation github-project-automation bot moved this from Pending review to Working on it in Powertools for AWS Lambda (Java) Oct 16, 2025
Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@kjswaruph
Copy link
Contributor Author

@phipag Sorry for the earlier confusion with the pr, I accidentally messed up the history while resolving merge conflicts. I have now cleaned up the branch and removed the Avro priming as requested. Please review again and let me know if there’s anything else needed.

Copy link
Contributor

@phipag phipag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kjswaruph. This looks good to me. Can you please commit these two formatting fixes?

@github-project-automation github-project-automation bot moved this from Working on it to Pending review in Powertools for AWS Lambda (Java) Oct 16, 2025
Co-authored-by: Philipp Page <philipp.page@yahoo.de>
@kjswaruph
Copy link
Contributor Author

@phipag Done

phipag
phipag previously approved these changes Oct 16, 2025
phipag
phipag previously approved these changes Oct 16, 2025
Copy link

@phipag phipag merged commit b923cd0 into aws-powertools:main Oct 16, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from Pending review to Coming soon in Powertools for AWS Lambda (Java) Oct 16, 2025
@phipag phipag linked an issue Oct 16, 2025 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Coming soon

Development

Successfully merging this pull request may close these issues.

Feature request: Priming for powertools-kafka

4 participants