Updated readmes to improve copy pastability

Also added instructions for native compilation for those apps that it is useful

Added documentation for native compilation when using Single Step Batch Processing

Updated documentaiton for native compilation for single app processing
This commit is contained in:
Glenn Renfro
2022-10-05 14:37:12 -04:00
parent 704667d542
commit b7b7de5337
13 changed files with 144 additions and 49 deletions

View File

@@ -365,6 +365,32 @@ itself by setting the following properties:
See the https://docs.spring.io/spring-batch/docs/4.3.x/api/org/springframework/batch/item/kafka/KafkaItemReader.html[`KafkaItemReader` documentation].
[[nativeCompilation]]
=== Native Compilation
The advantage of Single Step Batch Processing is that it lets you dynamically select which reader and writer beans to use at runtime when you use the JVM.
However, when you use native compilation, you must determine the reader and writer at build time instead of runtime.
The following example does so:
[source,xml]
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>process-aot</id>
<goals>
<goal>process-aot</goal>
</goals>
<configuration>
<jvmArguments>
-Dspring.batch.job.flatfileitemreader.name=fooReader
-Dspring.batch.job.flatfileitemwriter.name=fooWriter
</jvmArguments>
</configuration>
</execution>
</executions>
</plugin>
[[item-processors]]
== ItemProcessor Configuration

View File

@@ -373,9 +373,8 @@ NOTE: The exit code for the application will be 1 if the task fails because this
is enabled and another task is running with the same task name.
==== Single Instance Usage for Spring AOT And Native Compilation
To utilize Spring Cloud Task's single instance feature when creating a natively compiled app, the feature needs to 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 as shown below:
To use Spring Cloud Task's single-instance feature when creating a natively compiled app, you need to enable the feature at build time.
To do so, add the process-aot execution and set `spring.cloud.task.single-step-instance-enabled=true` as a JVM argument, as follows:
[source,xml]
<plugin>
<groupId>org.springframework.boot</groupId>

View File

@@ -18,22 +18,22 @@ Note: More information on this topic is available https://docs.spring.io/spring-
== Build:
[source,shell,indent=2]
[source,shell]
----
$ ./mvnw clean install
./mvnw clean install
----
== Execution:
[source,shell,indent=2]
[source,shell]
----
$ java -jar target/batch-events-3.0.0.jar
java -jar target/batch-events-3.0.0.jar
----
For example you can listen for specific job execution events on a specified channel with a Spring Cloud Stream Sink
For example, you can listen for specific job-execution events on a specified channel with a Spring Cloud Stream Sink
like the https://github.com/spring-cloud/stream-applications/tree/main/applications/sink/log-sink[log sink] using the following:
[source,shell,indent=2]
[source,shell]
----
$ java -jar <PATH_TO_LOG_SINK_JAR>/log-sink-rabbit-3.1.1.jar --server.port=9090
--spring.cloud.stream.bindings.input.destination=job-execution-events

View File

@@ -13,14 +13,28 @@ This is a Spring Cloud Task application that executes two simple Spring Batch Jo
== Build:
[source,shell,indent=2]
[source,shell]
----
$ mvn clean package
mvn clean package
----
== Run:
[source,shell,indent=2]
[source,shell]
----
$ java -jar target/batch-job-3.0.0.jar
java -jar target/batch-job-3.0.0.jar
----
== Native Build:
[source,shell]
----
mvn -Pnative clean package
----
== Native Run:
[source,shell]
----
./target/batch-job
----

View File

@@ -15,14 +15,28 @@ a data store.
== Build:
[source,shell,indent=2]
[source,shell]
----
$ mvn clean package
mvn clean package
----
== Run:
[source,shell,indent=2]
[source,shell]
----
$ java -jar target/jpa-sample-3.0.0.jar
java -jar target/jpa-sample-3.0.0.jar
----
== Native Build:
[source,shell]
----
mvn -Pnative clean package
----
== Native Run:
[source,shell]
----
./target/jpa-sample
----

View File

@@ -18,16 +18,30 @@ which one to be used for the Spring Cloud Task repository.
== Build:
[source,shell,indent=2]
[source,shell]
----
$ mvn clean package
mvn clean package
----
== Execute sample using 2 embedded databases (default):
[source,shell,indent=2]
[source,shell]
----
$ java -jar target/multiple-datasources-3.0.0.jar
java -jar target/multiple-datasources-3.0.0.jar
----
== Native Build:
[source,shell]
----
mvn -Pnative clean package
----
== RUn sample using 2 embedded databases (default) with native app:
[source,shell]
----
./target/multiple-datasources
----
== Execute sample using 2 external databases:

View File

@@ -9,14 +9,14 @@ An example of the usage of the `DeployerPartitionHandler` and
== Build:
[source,shell,indent=2]
[source,shell]
----
$ ./mvnw clean install
./mvnw clean install
----
== Execute:
[source,shell,indent=2]
[source,shell]
----
export SPRING_APPLICATION_JSON='{"spring.datasource.url":"jdbc:mariadb://localhost:3306/<your database>","spring.datasource.password":"<your password>","spring.datasource.username":"<your username>","spring.datasource.driverClassName":"org.mariadb.jdbc.Driver"}'
java -jar target/partitioned-batch-job-3.0.0.jar

View File

@@ -23,16 +23,16 @@ The profiles that are available are:
== Build:
[source,shell,indent=2]
[source,shell]
----
$ mvn clean package
mvn clean package
----
== Run:
[source,shell,indent=2]
[source,shell]
----
$ java -jar target/single-step-batch-job-3.0.0-SNAPSHOT.jar --spring.config.name=<property file containing batch, reader, and writer properties>
java -jar target/single-step-batch-job-3.0.0-SNAPSHOT.jar --spring.config.name=<property file containing batch, reader, and writer properties>
----
== Examples

View File

@@ -8,24 +8,24 @@ This is a task application that emits events on a channel named `task-events`
== Build:
[source,shell,indent=2]
[source,shell]
----
$ ./mvnw clean install
./mvnw clean install
----
== Execution:
[source,shell,indent=2]
[source,shell]
----
$ java -jar target/task-events-3.0.0.RELEASE.jar
java -jar target/task-events-3.0.0.RELEASE.jar
----
You can listen for the events on the task-events channel with a Spring Cloud Stream Sink
like the https://github.com/spring-cloud/stream-applications/tree/main/applications/sink/log-sink[log sink] using the following:
[source,shell,indent=2]
[source,shell]
----
$ java -jar <PATH_TO_LOG_SINK_JAR>/log-sink-rabbit-3.1.1.jar --server.port=9090 --spring.cloud.stream.bindings.input.destination=task-events
java -jar <PATH_TO_LOG_SINK_JAR>/log-sink-rabbit-3.1.1.jar --server.port=9090 --spring.cloud.stream.bindings.input.destination=task-events
----
== Dependencies:

View File

@@ -9,18 +9,32 @@ metrics at the end of the application using the SimpleMeterRegistry.
== Classes:
* TaskMetricsApplication - the Spring Boot Main Application
* TaskObservationsApplication - the Spring Boot Main Application
== Build:
[source,shell,indent=2]
[source,shell]
----
$ mvn clean package
mvn clean package
----
== Run:
[source,shell,indent=2]
[source,shell]
----
$ java -jar target/task-metrics-3.0.0-SNAPSHOT.jar
java -jar target/task-observations-3.0.0.jar
----
== Native Build:
[source,shell]
----
mvn -Pnative clean package
----
== Native Run:
[source,shell]
----
./target/task-observations
----

View File

@@ -11,9 +11,9 @@ specified.
NOTE: if using defaults make sure to install the timestamp-task into your local maven repo
by executing the following build in the timestamp-task module:
[source,shell,indent=2]
[source,shell]
----
$ ./mvnw clean install
./mvnw clean install
----
== The arguments offered by the TaskProcessor are as follows:
@@ -32,9 +32,9 @@ $ ./mvnw clean install
== Build:
[source,shell,indent=2]
[source,shell]
----
$ ./mvnw clean install
./mvnw clean install
----
== Dependencies:

View File

@@ -9,9 +9,9 @@ launch the task that was specified in the request.
== Build:
[source,shell,indent=2]
[source,shell]
----
$ ./mvnw clean install
./mvnw clean install
----
== Dependencies:

View File

@@ -13,14 +13,28 @@ This is a Spring Cloud Task application that logs a timestamp.
== Build:
[source,shell,indent=2]
[source,shell]
----
$ mvn clean package
mvn clean package
----
== Run:
[source,shell,indent=2]
[source,shell]
----
$ java -jar target/timestamp-task-3.0.0.jar
java -jar target/timestamp-task-3.0.0.jar
----
== Native Build:
[source,shell]
----
mvn -Pnative clean package
----
== Native Run:
[source,shell]
----
./target/timestamp-task
----