Skip to content

Commit

Permalink
Deprecate container factory customizer (#842)
Browse files Browse the repository at this point in the history
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 `PulsarContainerFactoryCustomizer` that
removes the need for this customizer.

This commit deprecates the Spring for Apache Pulsar customizer in favor
of the Spring Boot provided generic container factory customizer.
  • Loading branch information
onobc committed Sep 11, 2024
1 parent 8ed6689 commit 27c9747
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ These settings affect all listener containers, including the ones used by `@Puls

When not using Spring Boot, you can adjust these settings on the container factory that you provide.
However, when using Spring Boot, the container factory is auto-configured.
In this case you can register a `ConcurrentPulsarListenerContainerFactoryCustomizer` bean to access and customize the container properties.
In this case you can register a `org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactory<?>>` bean to access and customize the container properties.
The following example shows how to set the timeout on the container factory:

[source, java]
----
@Bean
ConcurrentPulsarListenerContainerFactoryCustomizer<?> containerCustomizer() {
PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactory<?>> containerCustomizer() {
return (containerFactory) -> containerFactory.getContainerProperties().transactions().setTimeout(Duration.ofSeconds(45));
}
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ See xref:./reference/default-tenant-namespace.adoc[Default Tenant / Namespace] f
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 xref:./reference/pulsar/message-consumption.adoc#message-listener-startup-failure[@PulsarListener], xref:./reference/pulsar/message-consumption.adoc#message-reader-startup-failure[@PulsarReader], or xref:./reference/reactive-pulsar/reactive-message-consumption.adoc#message-listener-startup-failure[@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
Expand All @@ -40,6 +48,13 @@ As part of this, the following APIs were deprecated, copied, and renamed:

- `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<?>>`.



=== Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* @author Chris Bono
*/
@SuppressWarnings("removal")
class ConcurrentPulsarListenerContainerFactoryBeanCustomizerPostProcessor
implements BeanPostProcessor, ApplicationContextAware {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
*
* @param <T> The message payload type
* @author Chris Bono
* @deprecated since 1.2.0 for removal in 1.4.0 in favor of
* {@code org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactory<?>>}
*/
@FunctionalInterface
@Deprecated(since = "1.2.0", forRemoval = true)
public interface ConcurrentPulsarListenerContainerFactoryCustomizer<T> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*
* @author Chris Bono
*/
@SuppressWarnings("removal")
class ConcurrentPulsarListenerContainerFactoryCustomizerTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
*
* @author Chris Bono
*/
@SuppressWarnings("removal")
class PulsarListenerTxnTests extends PulsarTxnTestsBase {

@Nested
Expand Down

0 comments on commit 27c9747

Please sign in to comment.