You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/01/08 15:22:28 UTC

[GitHub] stepanbujnak opened a new issue #3332: Cannot use topics regex pattern with using Go package (v2.2.1)

stepanbujnak opened a new issue #3332: Cannot use topics regex pattern with using Go package (v2.2.1)
URL: https://github.com/apache/pulsar/issues/3332
 
 
   I'm trying to subscribe to multiple topics specified by regex pattern using following code:
   
   ```go
   package main
   
   import (
     "context"
     "fmt"
   
     "github.com/apache/incubator-pulsar/pulsar-client-go/pulsar"
   )
   
   func main() {
     client, err := pulsar.NewClient(pulsar.ClientOptions{
       URL: "http://127.0.0.1:8080",
     })
     if err != nil {
       panic(err)
     }
     defer client.Close()
   
     consumer, err := client.Subscribe(pulsar.ConsumerOptions{
       TopicsPattern:    "persistent://foo/bar/test-\\d\\d",
       SubscriptionName: "test",
       Type:             pulsar.Shared,
     })
     if err != nil {
       panic(err)
     }
     defer consumer.Close()
   
     for {
       cm, err := consumer.Receive(context.Background())
       if err != nil {
         panic(err)
       }
   
       fmt.Println(cm)
       consumer.Ack(cm)
     }
   }
   ```
   
   However the program immediately fails with:
   
   ```
   INFO  | HTTPLookupService:222 | Curl Lookup Request sent for http://127.0.0.1:8080/admin/v2/namespaces/foo/bar/topics
   INFO  | HTTPLookupService:236 | Response received for url http://127.0.0.1:8080/admin/v2/namespaces/foo/bar/topics code 200
   terminate called after throwing an instance of 'Json::LogicError'
     what():  in Json::Value::resolveReference(key, end): requires objectValue
   signal: aborted (core dumped)
   ```
   
   It seems that it successfully retrieves the list of topics for tenant/namespace but fails to parse the response. When curling the endpoint I get:
   
   ```
   $ curl -L 'http://127.0.0.1:8080/admin/v2/namespaces/foo/bar/topics'
   ["persistent://foo/bar/test-aa","persistent://foo/bar/test-ab"]
   ```
   
   This is not what the undelying C++ library expects as seen [here](https://github.com/apache/pulsar/blob/v2.2.1/pulsar-client-cpp/lib/HTTPLookupService.cc#L319). It seems that it looks for a document with key `topics` in it but all it gets is JSON array.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services