Skip to content

AOT transformations and native image support

Olga Maciaszek-Sharma edited this page Dec 16, 2022 · 1 revision

As of 2022.0, most of the Spring Cloud projects support Spring Boot's ahead-of-time transformations, as well as building and running Spring Cloud components as native images. However, there are some limitations, as listed below.

Refresh Scope

Refresh Scope is not supported for any Spring Cloud applications in AOT and native image. The spring.cloud.refresh.enabled flag needs to be set to false.

Spring Cloud Config

Spring Cloud Config Server is blocked by graal#5134 and will likely require the completion of the work on https://github.com/graalvm/taming-build-time-initialization to be fixed.

Spring Cloud Config Client is supported for AOT and native image, however, the user must ensure that the configuration data source that it connects to (such as, Spring Cloud Config Server, Consul, Zookeeper, Vault, etc.) is available at build time. In order to avoid unexpected behaviour, any properties that would influence bean creation (such as the ones used within bootstrap context) should be set to the same values at build time and runtime. Since Config Client connects to a running data source (such as Config Server) while starting up from native image, the quick startup time will be slowed down by the time required for this network communication to take place.

The legacy config processing (Config First Bootstrap) mode does not support AOT or native images.

Spring Cloud LoadBalancer

In order for load-balancing to work with AOT and native images, all the LoadBalancerClient service IDs have to be explicitly defined by the user. However, to use this feature. It can be done by using the value or name attributes of the @LoadBalancerClient annotation or as values of the spring.cloud.loadbalancer.eager-load.clients property.

Spring Cloud Netflix

Spring Cloud Netflix Eureka Server does not support AOT or native images.

Spring Cloud Stream

Spring Cloud Stream has a component called StreamBridge which is effectively a template to send messages - messages that can be represented as Spring Message as well as any primitive or POJO. For example streamBridge.send(“myQueue”, “Hello stream”)or streamBridge.send(“myQueue”, new Foo()). The issue is that we do not know what user may send and thus can not introspect it which means the user would need to know the types they may be sending and add them as hints via @RegisterReflectionForBinding(Foo.class).

Spring Cloud Kubernetes

At this point, Spring Cloud Kubernetes does not support Spring Boot AOT transformations or native images. Partial support might be added in future releases.

Spring Cloud Task

To utilize Spring Cloud Task’s single instance feature when creating a natively compiled app, the feature needs to be enabled at build time. This is done by adding the process-aot execution and setting the spring.cloud.task.single-step-instance-enabled=true as a JVM argument.

Single Step Batch Job reader and writer selection needs to be specified at build time.