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
Contributor

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!

- 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 force-pushed the feat/add-crac-priming-to-kafka-module branch from 2355544 to 46f66e3 Compare October 4, 2025 10:49
Copy link

sonarqubecloud bot commented Oct 4, 2025

@kjswaruph
Copy link
Contributor Author

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

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

Labels

Projects

Status: Working on it

Development

Successfully merging this pull request may close these issues.

3 participants