Open weltonrodrigo opened 1 year ago
While we provided some hints to get a basic Spring for Apache Kafka application running as a native image, we (Spring) can't take on the responsibility of making all aspects of the kafka-clients
native compatible.
You can add your own hints or reproduce the issue without Spring and raise an issue over there.
If you get it working with your own hints, we'd consider accepting a PR, if you want to contribute it.
I'd prefer to have Apache Kafka client-specific native hints exactly in Apache Kafka.
Spring does nothing with that reflection around org.apache.kafka.common.security.authenticator.SaslClientCallbackHandler
, so it is unfair to ask us to fix something what really is out of this project scope.
Sure! It is easy to have a RuntimeHintsRegistrar
implementation for Spring AOT, but it is already a target project feature if you can't convince Apache Kafka to add native images support.
I've got my Spring Kafka consumers compiling as native image. There is a core Java security hint needed in my case which I am narrowing down from the dump I got from the tracing agent.
The kicker for me right now is the ErrorHandlingDeserializer, since it serializes exceptions into the header. I plan to implement a version that just stores the stack trace instead.
that just stores the stack trace instead.
The DeadLetterPublishingRecoverer
(or any recoverer that wants to analyze the problem) needs access to the raw data (byte[]
) that couldn't be deserialized (currently a field on the DeserializationException
).
I suppose you could add that as a separate header and add code to the DLPR to get it from there, if present.
Feel free to submit a PR with these changes.
that just stores the stack trace instead.
The
DeadLetterPublishingRecoverer
needs access to the raw data (byte[]
) that couldn't be deserialized (currently a field on theDeserializationException
.I suppose you could add that as a separate header and add code to the DLPR to get it from there, if present.
Feel free to submit a PR with these changes.
Ah interesting I see now. I'll take a look!
I've got this working and we've been using it in production all year. I want to submit a PR but when I went to write the tests to submit the PR for spring-kafka, I realized it's not going to be simple.
Can't try and fake-out the static variable that indicates whether we're running in native or not because of the way tests start up. I think I'll have to actually make the tests run in native.
@matthenry87 What changes are we talking about here? Is this still about the original report (SaslClientCallbackHandler
) or something else? Did you add any native hints that are specific to Spring Kafka? If it is some native-specific features that you are trying to test, we have a dedicated project for that: https://github.com/spring-projects/spring-aot-smoke-tests/tree/main/integration/spring-kafka. Maybe you can test your native features via the smoke tests? But we would like to see where the underlying changes are happening. Thanks!
@matthenry87 What changes are we talking about here? Is this still about the original report (
SaslClientCallbackHandler
) or something else? Did you add any native hints that are specific to Spring Kafka? If it is some native-specific features that you are trying to test, we have a dedicated project for that: https://github.com/spring-projects/spring-aot-smoke-tests/tree/main/integration/spring-kafka. Maybe you can test your native features via the smoke tests? But we would like to see where the underlying changes are happening. Thanks!
My changes are the ones mentioned above that enable a consumer running native. They do include a hint for the original report, and we're even using IAM authentication with MSK.
I'll have a look at those tests.
If the hints are specifically for components outside of Spring Kafka, it might be better to add them in Oracle's graalvm-reachability-metadata repository. Take look here for example: https://github.com/oracle/graalvm-reachability-metadata/blob/master/metadata/org.apache.kafka/kafka-clients/3.5.1/reflect-config.json.
In what version(s) of Spring for Apache Kafka are you seeing this issue? spring-kafka:3.0.4 kafka-clients:3.3.2
Describe the bug
Tryied to create a native springboot with kafka using microsoft azure eventhub Kafka layer. That uses SASL PLAIN.
Run as docker image build with
mvn -DskipTests -Pnative,nativeTest spring-boot:build-image
Failure to create KafkaConsumer Caused by: org.apache.kafka.common.KafkaException: org.apache.kafka.common.KafkaException: Could not find a public no-argument constructor for org.apache.kafka.common.security.authenticator.SaslClientCallbackHandler
To Reproduce
Using the following application.properties:
Expected behavior
With the normal (non-native), the app runs normally.
Maybe related: https://github.com/spring-projects/spring-kafka/issues/2545
Stacktrace