Split sample apps into multi-modules (#186)

This commit is contained in:
Chris Bono
2022-10-29 14:39:52 -05:00
committed by GitHub
parent fed6a0c40f
commit 87e349066b
11 changed files with 56 additions and 36 deletions

View File

@@ -26,5 +26,6 @@ include 'spring-pulsar'
include 'spring-pulsar-dependencies'
include 'spring-pulsar-spring-boot-autoconfigure'
include 'spring-pulsar-spring-boot-starter'
include 'spring-pulsar-sample-apps'
include 'spring-pulsar-sample-apps:sample-app1'
include 'spring-pulsar-sample-apps:sample-app2'
include 'spring-pulsar-docs'

View File

@@ -28,7 +28,7 @@ task aggregatedJavadoc(type: Javadoc) {
title = "${rootProject.description} ${version} API"
project.rootProject.gradle.projectsEvaluated {
Set<String> excludedProjects = ['spring-pulsar-sample-apps']
Set<String> excludedProjects = ['spring-pulsar-sample-apps:sample-app1', 'spring-pulsar-sample-apps:sample-app2']
Set<Project> publishedProjects = rootProject.subprojects.findAll { it != project}
.findAll { it.plugins.hasPlugin(JavaPlugin) && it.plugins.hasPlugin(MavenPublishPlugin) }
.findAll { !excludedProjects.contains(it.name) }

View File

@@ -23,18 +23,18 @@ TIP: The included link:../tools/pulsar/docker/README.adoc#_start_pulsar[Pulsar t
****
=== Steps
Make sure the above pre-requisites are satisfied and that you are in the `spring-pulsar-sample-apps` directory and follow the steps below.
=== App1
To start the link:./src/main/java/app1/SpringPulsarBootApp.java[SpringPulsarBootApp] run the following command:
Make sure the above pre-requisites are satisfied.
===== IDE
To run the app in your IDE just choose `Run/Debug` on the desired sample application class.
===== Command Line
To run the app on the command line open a terminal and navigate to the desired sample application directory (underneath `spring-pulsar-sample-apps`) and execute the following command:
[source,bash]
----
../gradlew bootRunApp1
../../gradlew bootRun
----
=== App2
To start the link:./src/main/java/app2/FailoverConsumerApp.java[FailoverConsumerApp] run the following command:
[source,bash]
----
../gradlew bootRunApp2
----
TIP: When running on the command line the `add-opens` JVM args are automatically configured which prevents annoying exceptions at runtime.

View File

@@ -3,7 +3,7 @@ plugins {
id 'org.springframework.boot' version '3.0.0-SNAPSHOT'
}
description = 'Spring Pulsar Sample Applications'
description = 'Spring Pulsar Sample Application (Send and Receive)'
dependencies {
api project(':spring-pulsar-spring-boot-starter')
@@ -16,34 +16,12 @@ dependencies {
implementation 'io.zipkin.reporter2:zipkin-sender-urlconnection'
}
springBoot {
mainClass = 'app1.SpringPulsarBootApp' // default app to run
}
task bootRunApp1(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') {
group = 'application'
mainClass = 'app1.SpringPulsarBootApp'
bootRun {
jvmArgs = [
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
doFirst() {
classpath = sourceSets.main.runtimeClasspath
}
}
task bootRunApp2(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') {
group = 'application'
mainClass = 'app2.FailoverConsumerApp'
jvmArgs = [
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
doFirst() {
classpath = sourceSets.main.runtimeClasspath
}
}
project.afterEvaluate {

View File

@@ -0,0 +1,29 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id 'org.springframework.boot' version '3.0.0-SNAPSHOT'
}
description = 'Spring Pulsar Sample Applications (Custom Routing)'
dependencies {
api project(':spring-pulsar-spring-boot-starter')
implementation 'com.google.code.findbugs:jsr305'
// observability
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
implementation 'io.zipkin.reporter2:zipkin-sender-urlconnection'
}
bootRun {
jvmArgs = [
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
}
project.afterEvaluate {
project.tasks.artifactoryPublish.enabled(false)
}

View File

@@ -0,0 +1,12 @@
logging:
level:
org.apache.pulsar: error
management:
tracing:
enabled: false
sampling:
probability: 1.0
zipkin:
tracing:
endpoint: "http://localhost:9411/api/v2/spans"