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:

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

org.springframework.pulsar:spring-pulsar

org.apache.pulsar:pulsar-spring

org.springframework.pulsar:spring-pulsar-bom

org.apache.pulsar:pulsar-spring-bom

org.springframework.pulsar:spring-pulsar-test

org.apache.pulsar:pulsar-spring-test

org.springframework.boot:spring-boot-pulsar

org.apache.pulsar:pulsar-spring-boot-autoconfigure

org.springframework.boot:spring-boot-starter-pulsar

org.apache.pulsar:pulsar-spring-boot-starter

org.springframework.boot:spring-boot-starter-pulsar-test

org.apache.pulsar:pulsar-spring-boot-starter-test

org.springframework.cloud:spring-cloud-stream-binder-pulsar

org.apache.pulsar:pulsar-spring-cloud-stream-binder

Package org.springframework.pulsar

Package org.apache.pulsar.spring

Package org.springframework.boot.pulsar

Package org.apache.pulsar.spring.boot

Package org.springframework.cloud.stream.binder.pulsar

Package org.apache.pulsar.spring.cloud.stream.binder

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

TestImage.forContainer(PulsarContainer.class)

PulsarTestImage.createContainer()

TestImage.PULSAR.toString()

PulsarTestImage.getDefaultImage().asCanonicalNameString()

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.