Migration from Spring’s Pulsar support
Apache Pulsar support for Spring is derived from Spring for Apache Pulsar, also known as Spring Pulsar, from the Apache Pulsar starter and auto-configuration in Spring Boot, and from the Apache Pulsar binder in Spring Cloud Stream. This page describes where the project came from and what you need to change when you move an application to it.
1. Background
The project is derived from these works, all licensed under the Apache License, Version 2.0:
-
Spring for Apache Pulsar, also known as Spring Pulsar, in spring-projects/spring-pulsar: the core library and test utilities
-
The Apache Pulsar starter and auto-configuration in Spring Boot, in spring-projects/spring-boot: the Spring Boot auto-configuration and starters
-
The Apache Pulsar binder in Spring Cloud Stream, in spring-cloud/spring-cloud-stream: the Spring Cloud Stream binder
Those works remain the copyright of their original authors and contributors, as stated in the headers of the source files.
Further development happens under the Apache Pulsar project in the apache/pulsar-spring repository.
2. Updating your application
The Maven coordinates and Java packages have changed:
| Previous | New |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Package |
Package |
Package |
Package |
Package |
Package |
Replace the previous dependencies rather than adding the new ones next to them, so that the previous auto-configuration and binder are not also on the classpath.
Spring Boot does not manage the version of these artifacts, so you need to declare it, either on each dependency or by importing pulsar-spring-bom.
Spring Boot applications must also always set the pulsar.version property, since Spring Boot manages an older version of Pulsar.
It’s also recommended to set netty.version to the most recent 4.2.x release of Netty.
See Set the Pulsar and Netty Versions in Spring Boot for how to set them.
This project requires the Pulsar 5.0.x client, and has changed from pulsar-client-all to the unshaded artifacts, as described in Pulsar client.
Exclude pulsar-client-all if another dependency brings it in, and don’t use classes from org.apache.pulsar.shade.
The spring.pulsar.* and spring.cloud.stream.pulsar.* configuration properties have not changed.
3. Updating your tests
Spring Boot’s Pulsar tests create their containers with TestImage.forContainer(PulsarContainer.class), but TestImage is internal to the Spring Boot build and is not published.
If you have tests derived from them, use org.apache.pulsar.spring.test.support.PulsarTestImage from pulsar-spring-test instead:
| Previous | New |
|---|---|
|
|
|
|
The container uses the same startup settings as TestImage.PULSAR and defaults to the image of the Pulsar version that this project is built with.
You can select another version with PulsarTestImage.createContainer(String) or another image with PulsarTestImage.createContainer(DockerImageName).
See PulsarTestImage for more information.