== Kafka Binder based AOT/Native Sample Application This sample application demonstrates a Kafka binder based Spring Cloud Stream application running as a native image. === Application Details The application consists of a supplier that is generating a random string every second, a function that receives the generated string and uppercase it, and then finally a consumer that simply logs the uppercased function. The application comes with a standard configuration properties yaml file that activates all the functions in the application. It then specifies the necessary destinations for all the bindings. Some bindings rely on the default binding destinations (see the `application.yml` for details). In addition, the application expects Kafka to be available on `localhost:9092`. If that is not the case, please ensure to update that in `application.yml`. === Building and Verifying the Sample App Before we build and run the sample app as a native image, let us do a few preliminary verifications. Ensure that, you are using a graalVM compatible JVM. For example, when running this app, we used the following JVM. ``` java -version openjdk version "19.0.1" 2022-10-18 OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 19.0.1+10-jvmci-22.3-b08) OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 19.0.1+10-jvmci-22.3-b08, mixed mode, sharing) ``` ==== Testing in regular JVM mode First, let us run this application in regular JVM mode without generating any AOT or native specific information. Make sure that you are in the directory of this sample app: `samples/kafka-binder-native-app` ``` ./mvnw clean package ``` and then: ``` java -jar target/kafka-binder-native-app-0.0.1-SNAPSHOT.jar ``` You should see output similar to the following: ``` ++++++Received:MUCH ++++++Received:WOOD ++++++Received:COULD ++++++Received:A ++++++Received:WOODCHUCK ``` === Testing in AOT Mode Next, let us run the same app in AOT mode. ``` ./mvnw clean package -Pnative ``` and then: ``` java -Dspring.aot.enabled=true -jar target/kafka-binder-native-app-0.0.1-SNAPSHOT.jar ``` You should see the similar output as above. === Running the app as a native image Now that we verified that our app is working in regular and AOT mode, let us now take it to run it as a native executable. First, build the native image: ``` ./mvnw -Pnative native:compile ``` Then, run the generated executable: ``` ./target/kafka-binder-native-app ``` You should see output similar to what we got above.