What’s new?

What’s New in 1.2 Since 1.1

This section covers the changes made from version 1.1 to version 1.2.

Custom Object Mapper

You can provide your own Jackson ObjectMapper that Pulsar will use when producing and consuming JSON messages. See Custom Object Mapper for more details.

Default Tenant and Namespace

You can specify a default tenant and/or namespace to use when producing or consuming messages against a non-fully-qualified topic URL. See Default Tenant / Namespace for more details.

Message Container Startup Policy

You can now configure the message listener container startup failure policy to stop, continue, or retry. For more details see the corresponding section for one of the supported containers @PulsarListener, @PulsarReader, or @ReactivePulsarListener

Message Container Factory Customizers (Spring Boot)

Spring Boot has introduced a generic message container factory customizer org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>> that can be used to further configure one or more of the auto-configured container factories that back the following listener annotations:

  • For @PulsarListener register one or more PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactory<?>> beans.

  • For @PulsarReader register one or more PulsarContainerFactoryCustomizer<DefaultPulsarReaderContainerFactory<?>> beans.

  • For @ReactivePulsarListener register one or more PulsarContainerFactoryCustomizer<DefaultReactivePulsarListenerContainerFactory<?>> beans.

Deprecations

PulsarClient#getPartitionsForTopic(java.lang.String)

Version 3.3.1 of the Pulsar client deprecates the getPartitionsForTopic(java.lang.String) in favor of getPartitionsForTopic(java.lang.String, boolean metadataAutoCreationEnabled).

PulsarTopic#builder

When using Spring Boot the PulsarTopicBuilder is now a registered bean that is configured with default values for domain, tenant, and namespace. Therefore, if you are using Spring Boot, you can simply inject the builder where needed. Otherwise, use one of the PulsarTopicBuilder constructors directly.

Listener/ReaderContainerFactory

The PulsarContainerFactory common interface was introduced to bridge the gap between listener and reader container factories. As part of this, the following APIs were deprecated, copied, and renamed:

  • ListenerContainerFactory#createListenerContainer replaced with ListenerContainerFactory#createRegisteredContainer

  • ReaderContainerFactory#createReaderContainer(E endpoint) replaced with ReaderContainerFactory#createRegisteredContainer

  • ReaderContainerFactory#createReaderContainer(String…​ topics) replaced with ReaderContainerFactory#createContainer

ConcurrentPulsarListenerContainerFactoryCustomizer

The purpose of ConcurrentPulsarListenerContainerFactoryCustomizer was to customize the Spring Boot auto-configured message container factories. However, Spring Boot has introduced a generic message container factory customizer org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>> that removes the need for this customizer.

Replace all instances of ConcurrentPulsarListenerContainerFactoryCustomizer with org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactoryCustomizer<?>>.

Removals

The following previously deprecated listener endpoint adapters have been removed in favor of default methods in the listener endpoint interfaces:

  • org.springframework.pulsar.config.PulsarListenerEndpointAdapter

  • org.springframework.pulsar.reactive.config.ReactivePulsarListenerEndpointAdapter

Breaking Changes

PulsarTopic#<init>

The PulsarTopic constructor now requires a fully qualified topic name (domain://tenant/namespace/name). If you are invoking the constructor you will need to be sure the topic you pass in is fully-qualified. A better alternative is to instead use the PulsarTopicBuilder as it does not require fully qualified names and will add default values for the missing components in the specified name.

PulsarReaderFactory#createReader

The PulsarReaderFactory#createReader API now throws an unchecked PulsarException rather than a checked PulsarClientException. Replace any try/catch blocks on this API accordingly.

What’s New in 1.1 Since 1.0

This section covers the changes made from version 1.0 to version 1.1.

Auto Schema support

If there is no chance to know the schema of a Pulsar topic in advance, you can use AUTO Schemas to produce/consume generic records to/from brokers. See Producing with AUTO_SCHEMA and Consuming with AUTO_SCHEMA for more details.

While the above links focus on PulsarTemplate and @PulsarListener, this feature is also supported in ReactivePulsarTemplate, @ReactivePulsarListener, and @PulsarReader. Details for each can be found in their respective section of this reference guide.

Default topic/schema via message annotation

You can now mark a message class with @PulsarMessage to specify the default topic and/or default schema to use when producing/consuming messages of that type.

Remove checked exceptions

The APIs provided by the framework no longer throw the checked PulsarClientException, but rather the unchecked PulsarException.

If you were previously catching or rethrowing PulsarClientException just to appease the compiler and were not actually handling the exception, you can simply remove your catch or throws clause. If you were actually handling the exception then you will need to replace PulsarClientException with PulsarException in your catch clause.

Testing support

The spring-pulsar-test module is now available to help test your Spring for Apache Pulsar applications. See Testing Applications for more details.