-
Notifications
You must be signed in to change notification settings - Fork 108
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
Support for Graal Native image in micronaut-kafka #29
Comments
we are waiting for Micronaut 1.1 to be released then will upgrade the module to support Graal |
That's great news! Thanks. |
@graemerocher @kortatu what is the status of this issue? 1.1 is out for a while. |
Will look at this soon, shouldn't be too much work |
@ilopmar if you get to it before me let me now! |
I'm getting some other error messages if I implement a simple Producer. Are this errors related to this issue? Errors with
My Producer: import io.micronaut.configuration.kafka.annotation.KafkaClient;
import io.micronaut.configuration.kafka.annotation.Topic;
import java.util.concurrent.Future;
@KafkaClient
public interface PriceProducer {
@Topic("plain-prices")
Future<Integer> sendPrice(Integer price);
} My Controller: import io.micronaut.configuration.kafka.annotation.KafkaClient;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Post;
import java.util.concurrent.Future;
@Controller("/price")
public class PriceController {
private final PriceProducer priceProducerClient;
public PriceController(
@KafkaClient PriceProducer priceProducerClient) {
this.priceProducerClient = priceProducerClient;
}
@Post
public Future<Integer> add(Integer price) {
return priceProducerClient.sendPrice(price);
}
} I've also tried to set a reflection configuration, but without any result: [
{
"name" : "java.lang.invoke.MethodHandle",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredClasses" : true,
"allPublicClasses" : true
},
{
"name" : "java.lang.Class",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredClasses" : true,
"allPublicClasses" : true
}
] |
I have pushed the changes to include the Graal substrate metadata. However with Graal 19 it currently fails with:
I have raised oracle/graal#1342 to track this issue |
So with the master branch of micronaut core and this above commit Kafka + Micronaut now works with GraalVM native-image in 19.1 |
Hi everyone,
I'm trying to create a native image with Graal in a micronaut project that uses micronaut-kafka.
I have found several problems and I think I hit a wall here trying to solve it. I also thought it was interesting to writing down my progress in case there is someone there with more knowledge than me who can solve it or at least advance a bit more.
First thing was the known Snappy compressor in org.apache.kafka.common.record.CompressionType enum. SNAPPY wrapForInput and wrapForOutput uses a MethodHandle.invoke that is Unsupported by Graal. As I'm not using this compression, and it is just an option, I overwrote the class with a NonSupportedException return instead of using the invoke.
Maybe this can be done with @substitute in MicronautSubstitutions, but I have no clue how to substitute Enum values.
But anyway, copying the class in my project with the same package and name and changing the SNAPPY field implementation worked and the building of the native image continued.
After that the creation of the image finished, but when I tried to start up the application I got two errors of classes intantiated by reflection but not registered, so I added them manually to reflect.json:
{ "name" : "[Lio.micronaut.configuration.kafka.bind.ConsumerRecordBinder;", "allDeclaredConstructors" : true }, { "name" : "[Lio.micronaut.configuration.kafka.serde.SerdeRegistry;", "allDeclaredConstructors" : true }
But the next error I got, I have no idea how to fix it (or even if it is possible):
I guess the solution is to implement those proxies at compile time.
So this is where I can get to. Maybe I can implement my producer using directly KafkaClient so no proxy is involved.
I have also found this thread in Graal project: failed to compile simple kafka consumer app to native image, reflection issue #532
The text was updated successfully, but these errors were encountered: