From 62ef81b5c8a1f3641271e61a2851c80e689f39cd Mon Sep 17 00:00:00 2001 From: Chris Bono Date: Fri, 30 Aug 2024 14:27:57 -0500 Subject: [PATCH] Add subscription name to Pulsar mapped config props The subscription name config prop was not being set on the Pulsar listener container properties. This commit adds the subscription name to the Pulsar property mappers. See gh-42067 --- .../boot/autoconfigure/pulsar/PulsarPropertiesMapper.java | 1 + .../autoconfigure/pulsar/PulsarReactivePropertiesMapper.java | 1 + .../boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java | 2 ++ .../pulsar/PulsarReactivePropertiesMapperTests.java | 2 ++ 4 files changed, 6 insertions(+) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java index ad96d6031b84..f645616892b5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java @@ -190,6 +190,7 @@ private void customizePulsarContainerConsumerSubscriptionProperties(PulsarContai PulsarProperties.Consumer.Subscription properties = this.properties.getConsumer().getSubscription(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(properties::getType).to(containerProperties::setSubscriptionType); + map.from(properties::getName).to(containerProperties::setSubscriptionName); } private void customizePulsarContainerListenerProperties(PulsarContainerProperties containerProperties) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactivePropertiesMapper.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactivePropertiesMapper.java index 9abf379a5198..f936a6c8afcd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactivePropertiesMapper.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactivePropertiesMapper.java @@ -88,6 +88,7 @@ private void customizePulsarContainerConsumerSubscriptionProperties( PulsarProperties.Consumer.Subscription properties = this.properties.getConsumer().getSubscription(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(properties::getType).to(containerProperties::setSubscriptionType); + map.from(properties::getName).to(containerProperties::setSubscriptionName); } private void customizePulsarContainerListenerProperties(ReactivePulsarContainerProperties containerProperties) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java index baab6c4078f4..353d78ea128d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java @@ -262,12 +262,14 @@ void customizeConsumerBuilder() { void customizeContainerProperties() { PulsarProperties properties = new PulsarProperties(); properties.getConsumer().getSubscription().setType(SubscriptionType.Shared); + properties.getConsumer().getSubscription().setName("my-subscription"); properties.getListener().setSchemaType(SchemaType.AVRO); properties.getListener().setObservationEnabled(true); properties.getTransaction().setEnabled(true); PulsarContainerProperties containerProperties = new PulsarContainerProperties("my-topic-pattern"); new PulsarPropertiesMapper(properties).customizeContainerProperties(containerProperties); assertThat(containerProperties.getSubscriptionType()).isEqualTo(SubscriptionType.Shared); + assertThat(containerProperties.getSubscriptionName()).isEqualTo("my-subscription"); assertThat(containerProperties.getSchemaType()).isEqualTo(SchemaType.AVRO); assertThat(containerProperties.isObservationEnabled()).isTrue(); assertThat(containerProperties.transactions().isEnabled()).isTrue(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactivePropertiesMapperTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactivePropertiesMapperTests.java index b31de0290322..1c45f1aa9c09 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactivePropertiesMapperTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarReactivePropertiesMapperTests.java @@ -120,11 +120,13 @@ void customizeMessageConsumerBuilder() { void customizeContainerProperties() { PulsarProperties properties = new PulsarProperties(); properties.getConsumer().getSubscription().setType(SubscriptionType.Shared); + properties.getConsumer().getSubscription().setName("my-subscription"); properties.getListener().setSchemaType(SchemaType.AVRO); properties.getListener().setConcurrency(10); ReactivePulsarContainerProperties containerProperties = new ReactivePulsarContainerProperties<>(); new PulsarReactivePropertiesMapper(properties).customizeContainerProperties(containerProperties); assertThat(containerProperties.getSubscriptionType()).isEqualTo(SubscriptionType.Shared); + assertThat(containerProperties.getSubscriptionName()).isEqualTo("my-subscription"); assertThat(containerProperties.getSchemaType()).isEqualTo(SchemaType.AVRO); assertThat(containerProperties.getConcurrency()).isEqualTo(10); }