Skip to content

Commit 26bf8c0

Browse files
wilkinsonasnicoll
authored andcommitted
Create spring-boot-pulsar module
1 parent a11aad9 commit 26bf8c0

File tree

41 files changed

+125
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+125
-95
lines changed

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ include "spring-boot-project:spring-boot-kafka"
6464
include "spring-boot-project:spring-boot-liquibase"
6565
include "spring-boot-project:spring-boot-mail"
6666
include "spring-boot-project:spring-boot-parent"
67+
include "spring-boot-project:spring-boot-pulsar"
6768
include "spring-boot-project:spring-boot-reactor-netty"
6869
include "spring-boot-project:spring-boot-test"
6970
include "spring-boot-project:spring-boot-test-autoconfigure"

spring-boot-project/spring-boot-autoconfigure-all/build.gradle

-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ dependencies {
3939
dockerTestImplementation("org.testcontainers:junit-jupiter")
4040
dockerTestImplementation("org.testcontainers:mongodb")
4141
dockerTestImplementation("org.testcontainers:neo4j")
42-
dockerTestImplementation("org.testcontainers:pulsar")
4342
dockerTestImplementation("org.testcontainers:testcontainers")
4443

4544
optional(project(":spring-boot-project:spring-boot-activemq"))
@@ -194,8 +193,6 @@ dependencies {
194193
optional("org.springframework.data:spring-data-redis")
195194
optional("org.springframework.graphql:spring-graphql")
196195
optional("org.springframework.hateoas:spring-hateoas")
197-
optional("org.springframework.pulsar:spring-pulsar")
198-
optional("org.springframework.pulsar:spring-pulsar-reactive")
199196
optional("org.springframework.security:spring-security-acl")
200197
optional("org.springframework.security:spring-security-config")
201198
optional("org.springframework.security:spring-security-data") {
@@ -260,7 +257,6 @@ dependencies {
260257
testImplementation("org.postgresql:postgresql")
261258
testImplementation("org.postgresql:r2dbc-postgresql")
262259
testImplementation("org.springframework.graphql:spring-graphql-test")
263-
testImplementation("org.springframework.pulsar:spring-pulsar-cache-provider-caffeine")
264260
testImplementation("org.springframework.security:spring-security-test")
265261
testImplementation("org.yaml:snakeyaml")
266262

spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json

-18
Original file line numberDiff line numberDiff line change
@@ -1107,24 +1107,6 @@
11071107
"name": "spring.neo4j.uri",
11081108
"defaultValue": "bolt://localhost:7687"
11091109
},
1110-
{
1111-
"name": "spring.pulsar.defaults.topic.enabled",
1112-
"type": "java.lang.Boolean",
1113-
"description": "Whether to enable default tenant and namespace support for topics.",
1114-
"defaultValue": true
1115-
},
1116-
{
1117-
"name": "spring.pulsar.function.enabled",
1118-
"type": "java.lang.Boolean",
1119-
"description": "Whether to enable function support.",
1120-
"defaultValue": true
1121-
},
1122-
{
1123-
"name": "spring.pulsar.producer.cache.enabled",
1124-
"type": "java.lang.Boolean",
1125-
"description": "Whether to enable caching in the PulsarProducerFactory.",
1126-
"defaultValue": true
1127-
},
11281110
{
11291111
"name": "spring.quartz.jdbc.comment-prefix",
11301112
"defaultValue": [

spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration
6363
org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration
6464
org.springframework.boot.autoconfigure.netty.NettyAutoConfiguration
6565
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
66-
org.springframework.boot.autoconfigure.pulsar.PulsarAutoConfiguration
67-
org.springframework.boot.autoconfigure.pulsar.PulsarReactiveAutoConfiguration
6866
org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration
6967
org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration
7068
org.springframework.boot.autoconfigure.r2dbc.R2dbcInitializationAutoConfiguration

spring-boot-project/spring-boot-dependencies/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,7 @@ bom {
20472047
"spring-boot-loader-tools",
20482048
"spring-boot-mail",
20492049
"spring-boot-properties-migrator",
2050+
"spring-boot-pulsar",
20502051
"spring-boot-reactor-netty",
20512052
"spring-boot-starter",
20522053
"spring-boot-starter-activemq",

spring-boot-project/spring-boot-docker-compose/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies {
1414
dockerTestImplementation(project(":spring-boot-project:spring-boot-jdbc"))
1515
dockerTestImplementation(project(":spring-boot-project:spring-boot-flyway"))
1616
dockerTestImplementation(project(":spring-boot-project:spring-boot-liquibase"))
17+
dockerTestImplementation(project(":spring-boot-project:spring-boot-pulsar"))
1718
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
1819
dockerTestImplementation("com.hazelcast:hazelcast")
1920
dockerTestImplementation("com.redis:testcontainers-redis")
@@ -42,6 +43,7 @@ dependencies {
4243
optional(project(":spring-boot-project:spring-boot-flyway"))
4344
optional(project(":spring-boot-project:spring-boot-jdbc"))
4445
optional(project(":spring-boot-project:spring-boot-liquibase"))
46+
optional(project(":spring-boot-project:spring-boot-pulsar"))
4547
optional("com.hazelcast:hazelcast")
4648
optional("io.r2dbc:r2dbc-spi")
4749
optional("org.mongodb:mongodb-driver-core")

spring-boot-project/spring-boot-docker-compose/src/dockerTest/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactoryIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
1616

1717
package org.springframework.boot.docker.compose.service.connection.pulsar;
1818

19-
import org.springframework.boot.autoconfigure.pulsar.PulsarConnectionDetails;
2019
import org.springframework.boot.docker.compose.service.connection.test.DockerComposeTest;
20+
import org.springframework.boot.pulsar.autoconfigure.PulsarConnectionDetails;
2121
import org.springframework.boot.testsupport.container.TestImage;
2222

2323
import static org.assertj.core.api.Assertions.assertThat;

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactory.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,11 +16,11 @@
1616

1717
package org.springframework.boot.docker.compose.service.connection.pulsar;
1818

19-
import org.springframework.boot.autoconfigure.pulsar.PulsarConnectionDetails;
2019
import org.springframework.boot.docker.compose.core.ConnectionPorts;
2120
import org.springframework.boot.docker.compose.core.RunningService;
2221
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
2322
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionSource;
23+
import org.springframework.boot.pulsar.autoconfigure.PulsarConnectionDetails;
2424

2525
/**
2626
* {@link DockerComposeConnectionDetailsFactory} to create {@link PulsarConnectionDetails}

spring-boot-project/spring-boot-docs/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dependencies {
6868
autoConfiguration(project(path: ":spring-boot-project:spring-boot-kafka", configuration: "autoConfigurationMetadata"))
6969
autoConfiguration(project(path: ":spring-boot-project:spring-boot-liquibase", configuration: "autoConfigurationMetadata"))
7070
autoConfiguration(project(path: ":spring-boot-project:spring-boot-mail", configuration: "autoConfigurationMetadata"))
71+
autoConfiguration(project(path: ":spring-boot-project:spring-boot-pulsar", configuration: "autoConfigurationMetadata"))
7172
autoConfiguration(project(path: ":spring-boot-project:spring-boot-reactor-netty", configuration: "autoConfigurationMetadata"))
7273
autoConfiguration(project(path: ":spring-boot-project:spring-boot-testcontainers", configuration: "autoConfigurationMetadata"))
7374
autoConfiguration(project(path: ":spring-boot-project:spring-boot-tomcat", configuration: "autoConfigurationMetadata"))
@@ -95,6 +96,7 @@ dependencies {
9596
configurationProperties(project(path: ":spring-boot-project:spring-boot-kafka", configuration: "configurationPropertiesMetadata"))
9697
configurationProperties(project(path: ":spring-boot-project:spring-boot-liquibase", configuration: "configurationPropertiesMetadata"))
9798
configurationProperties(project(path: ":spring-boot-project:spring-boot-mail", configuration: "configurationPropertiesMetadata"))
99+
configurationProperties(project(path: ":spring-boot-project:spring-boot-pulsar", configuration: "configurationPropertiesMetadata"))
98100
configurationProperties(project(path: ":spring-boot-project:spring-boot-reactor-netty", configuration: "configurationPropertiesMetadata"))
99101
configurationProperties(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "configurationPropertiesMetadata"))
100102
configurationProperties(project(path: ":spring-boot-project:spring-boot-testcontainers", configuration: "configurationPropertiesMetadata"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
plugins {
2+
id "java-library"
3+
id "org.springframework.boot.auto-configuration"
4+
id "org.springframework.boot.configuration-properties"
5+
id "org.springframework.boot.deployed"
6+
id "org.springframework.boot.docker-test"
7+
id "org.springframework.boot.optional-dependencies"
8+
}
9+
10+
description = "Spring Boot Pulsar"
11+
12+
dependencies {
13+
api(project(":spring-boot-project:spring-boot"))
14+
api("org.springframework.pulsar:spring-pulsar")
15+
16+
dockerTestImplementation(project(":spring-boot-project:spring-boot-test"))
17+
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
18+
dockerTestImplementation("org.testcontainers:junit-jupiter")
19+
dockerTestImplementation("org.testcontainers:pulsar")
20+
21+
optional("org.springframework.pulsar:spring-pulsar-reactive")
22+
23+
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
24+
25+
testImplementation(project(":spring-boot-project:spring-boot-test"))
26+
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
27+
testImplementation("com.github.ben-manes.caffeine:caffeine")
28+
testImplementation("org.springframework.pulsar:spring-pulsar-cache-provider-caffeine")
29+
30+
testRuntimeOnly("ch.qos.logback:logback-classic")
31+
}
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,17 @@
2626

2727
import org.springframework.beans.factory.annotation.Autowired;
2828
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
29-
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
30-
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
31-
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
32-
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
29+
import org.springframework.boot.pulsar.autoconfigure.PulsarAutoConfiguration;
30+
import org.springframework.boot.pulsar.autoconfigure.PulsarReactiveAutoConfiguration;
3331
import org.springframework.boot.test.context.SpringBootTest;
34-
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
35-
import org.springframework.boot.test.web.client.TestRestTemplate;
3632
import org.springframework.boot.testsupport.container.TestImage;
37-
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
3833
import org.springframework.context.annotation.Configuration;
3934
import org.springframework.context.annotation.Import;
4035
import org.springframework.pulsar.annotation.PulsarListener;
4136
import org.springframework.pulsar.core.PulsarTemplate;
37+
import org.springframework.stereotype.Service;
4238
import org.springframework.test.context.DynamicPropertyRegistry;
4339
import org.springframework.test.context.DynamicPropertySource;
44-
import org.springframework.web.bind.annotation.GetMapping;
45-
import org.springframework.web.bind.annotation.RestController;
4640

4741
import static org.assertj.core.api.Assertions.assertThat;
4842

@@ -52,7 +46,7 @@
5246
* @author Chris Bono
5347
* @author Phillip Webb
5448
*/
55-
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
49+
@SpringBootTest
5650
@Testcontainers(disabledWithoutDocker = true)
5751
class PulsarAutoConfigurationIntegrationTests {
5852

@@ -76,16 +70,14 @@ void appStartsWithAutoConfiguredSpringPulsarComponents(
7670
}
7771

7872
@Test
79-
void templateCanBeAccessedDuringWebRequest(@Autowired TestRestTemplate restTemplate) throws InterruptedException {
80-
assertThat(restTemplate.getForObject("/hello", String.class)).startsWith("Hello World -> ");
73+
void sendAndReceive(@Autowired TestService testService) throws InterruptedException {
74+
assertThat(testService.sayHello()).startsWith("Hello World -> ");
8175
assertThat(listenLatch.await(5, TimeUnit.SECONDS)).isTrue();
8276
}
8377

8478
@Configuration(proxyBeanMethods = false)
85-
@ImportAutoConfiguration({ DispatcherServletAutoConfiguration.class, TomcatServletWebServerAutoConfiguration.class,
86-
WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JacksonAutoConfiguration.class,
87-
PulsarAutoConfiguration.class, PulsarReactiveAutoConfiguration.class })
88-
@Import(TestWebController.class)
79+
@ImportAutoConfiguration({ PulsarAutoConfiguration.class, PulsarReactiveAutoConfiguration.class })
80+
@Import(TestService.class)
8981
static class TestConfiguration {
9082

9183
@PulsarListener(subscriptionName = TOPIC + "-sub", topics = TOPIC)
@@ -95,16 +87,15 @@ void listen(String ignored) {
9587

9688
}
9789

98-
@RestController
99-
static class TestWebController {
90+
@Service
91+
static class TestService {
10092

10193
private final PulsarTemplate<String> pulsarTemplate;
10294

103-
TestWebController(PulsarTemplate<String> pulsarTemplate) {
95+
TestService(PulsarTemplate<String> pulsarTemplate) {
10496
this.pulsarTemplate = pulsarTemplate;
10597
}
10698

107-
@GetMapping("/hello")
10899
String sayHello() {
109100
return "Hello World -> " + this.pulsarTemplate.send(TOPIC, "hello");
110101
}
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import org.apache.pulsar.client.api.DeadLetterPolicy;
2020
import org.apache.pulsar.client.api.DeadLetterPolicy.DeadLetterPolicyBuilder;
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
/**
2020
* Adapts {@link PulsarProperties} to {@link PulsarConnectionDetails}.
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import java.util.ArrayList;
2020
import java.util.List;
@@ -69,7 +69,7 @@
6969
* @author Alexander Preuß
7070
* @author Phillip Webb
7171
* @author Jonas Geiregat
72-
* @since 3.2.0
72+
* @since 4.0.0
7373
*/
7474
@AutoConfiguration
7575
@ConditionalOnClass({ PulsarClient.class, PulsarTemplate.class })
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import java.util.ArrayList;
2020
import java.util.List;
@@ -30,9 +30,9 @@
3030
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
3131
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
3232
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
33-
import org.springframework.boot.autoconfigure.pulsar.PulsarProperties.Defaults.SchemaInfo;
34-
import org.springframework.boot.autoconfigure.pulsar.PulsarProperties.Defaults.TypeMapping;
3533
import org.springframework.boot.context.properties.EnableConfigurationProperties;
34+
import org.springframework.boot.pulsar.autoconfigure.PulsarProperties.Defaults.SchemaInfo;
35+
import org.springframework.boot.pulsar.autoconfigure.PulsarProperties.Defaults.TypeMapping;
3636
import org.springframework.boot.util.LambdaSafe;
3737
import org.springframework.context.annotation.Bean;
3838
import org.springframework.context.annotation.Configuration;
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;
2020

2121
/**
2222
* Details required to establish a connection to a Pulsar service.
2323
*
2424
* @author Chris Bono
25-
* @since 3.2.0
25+
* @since 4.0.0
2626
*/
2727
public interface PulsarConnectionDetails extends ConnectionDetails {
2828

Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import org.springframework.pulsar.config.PulsarContainerFactory;
2020

@@ -25,7 +25,7 @@
2525
*
2626
* @param <T> the type of the {@link PulsarContainerFactory}
2727
* @author Chris Bono
28-
* @since 3.4.0
28+
* @since 4.0.0
2929
*/
3030
@FunctionalInterface
3131
public interface PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>> {
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import java.util.ArrayList;
2020
import java.util.Collections;
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import java.time.Duration;
2020
import java.util.ArrayList;
@@ -45,7 +45,7 @@
4545
* @author Phillip Webb
4646
* @author Swamy Mavuri
4747
* @author Vedran Pavic
48-
* @since 3.2.0
48+
* @since 4.0.0
4949
*/
5050
@ConfigurationProperties("spring.pulsar")
5151
public class PulsarProperties {
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import java.time.Duration;
2020
import java.util.ArrayList;
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.pulsar;
17+
package org.springframework.boot.pulsar.autoconfigure;
1818

1919
import java.time.Duration;
2020
import java.util.ArrayList;
@@ -65,7 +65,7 @@
6565
*
6666
* @author Chris Bono
6767
* @author Christophe Bornet
68-
* @since 3.2.0
68+
* @since 4.0.0
6969
*/
7070
@AutoConfiguration(after = PulsarAutoConfiguration.class)
7171
@ConditionalOnClass({ PulsarClient.class, ReactivePulsarClient.class, ReactivePulsarTemplate.class })

0 commit comments

Comments
 (0)