Skip to content

Setting subscription name using spring.pulsar.consumer.subscription.name configuration property doesn't work #480

@vpavic

Description

@vpavic

Pulsar Listener section of reference manual provides snippets that suggest it's possible to configure subscription name only using spring.pulsar.consumer.subscription.name configuration property and without having subscriptionName specified on @PulsarListener.

However, in practice, I don't see this being possible due to subscription name being generated in PulsarListenerAnnotationBeanPostProcessor if omitted on annotation:

private String getEndpointSubscriptionName(PulsarListener pulsarListener) {
if (StringUtils.hasText(pulsarListener.subscriptionName())) {
return resolveExpressionAsString(pulsarListener.subscriptionName(), "subscriptionName");
}
return GENERATED_ID_PREFIX + this.counter.getAndIncrement();
}

Which combined with DefaultPulsarConsumerFactory applying the generated subscription name to ConsumerBuilder results in the value specified by spring.pulsar.consumer.subscription.name configuration property being overwritten by generated one:

if (subscriptionName != null) {
consumerBuilder.subscriptionName(subscriptionName);
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions