javakotlinapache-pulsarpulsar

Getting number of partitions of a Pulsar topic: could not be parsed into a proper Uri, missing scheme


I'm unable to get the number of partitions from a topic via the PulsarAdmin API:

            val admin: PulsarAdmin =
                PulsarAdmin
                    .builder()
                    .authentication(authParams)
                    .serviceHttpUrl(serviceUrl)
                    .tlsTrustCertsFilePath(tlsTrustCertsFilePath)
                    .allowTlsInsecureConnection(tlsAllowInsecureConnection)
                    .build()

            println(serviceUrl)
            println(authParams) // params seem fine...
            
            // Error here: can't get number of partitions
            println(admin.topics().getPartitionedTopicMetadata(inputTopic))

Suggestions on this error? Online did not yield much.

Exception in thread "main" org.apache.pulsar.client.admin.PulsarAdminException: java.lang.IllegalArgumentException: pulsar+ssl://mypath.com:1234/admin/v2/persistent/abc/def/myplacev1/partitions could not be parsed into a proper Uri, missing scheme

The scheme is the pulsar+ssl part, afaik. I don't see what is wrong with this path.


Solution

  • Ended up side-stepping this issue after seeing the pulsar-flink connector code and finding PulsarClientImpl has a getNumberOfPartitions(topic) which worked.

    (client as PulsarClientImpl).getNumberOfPartitions(topic).get()