Skip to content

Unable to subscribe to different topics on different namespaces with Python client  #9449

@giacomo-porro

Description

@giacomo-porro

Describe the bug
Creating a consumer subscribed on different topics on different namespaces throws an error even if no regex pattern is used ( as per https://pulsar.incubator.apache.org/docs/en/concepts-messaging/#multi-topic-subscriptions )

To Reproduce
Steps to reproduce the behavior:

  1. Create a custom tenant on pulsar with pulsar admin
    bin/pulsar-admin tenants create my-tenant
  2. Create 2 different namespaces on that tenant with pulsar admin
bin/pulsar-admin namespaces create my-tenant/ns1
bin/pulsar-admin namespaces create my-tenant/ns2
  1. Create 2 topics, one per namespace with pulsar admin
bin/pulsar-admin topics create my-tenant/ns1/topic-1
bin/pulsar-admin topics create my-tenant/ns2/topic-2
  1. Run this code
import pulsar
from _pulsar import ConsumerType

def handle(consumer, message):
    print(message.value())

client = pulsar.Client(service_url="pulsar://localhost:36650")
consumer = client.subscribe(
            topic=["persistent://my-tenant/ns1/topic-1", "persistent://my-tenant/ns2/topic-2"],
            subscription_name="my-sub",
            consumer_type=ConsumerType.Shared,
            message_listener=handle,
            consumer_name="my-consumer-name"
        )

I get the error ERROR [0x11a3f7dc0] MultiTopicsConsumerImpl:737 | Different namespace name. expected: qa/users now:qa/accounts

I tried the same setup with the Java client and it works as expected

Expected behavior
The consumer should not throw an error and just connect correctly

Desktop (please complete the following information):

  • OS: MacOSX Catalina

Additional context
I tried with pulsar python client 2.6.1, 2.6.2 and 2.7.0 and all of them had the same issue

Metadata

Metadata

Assignees

Labels

type/bugThe PR fixed a bug or issue reported a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions