dapr / dapr/go-sdk

Pubsub subscription only finds messages for "neworder" topic

Open
#273 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
479
Forks
187
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

It appears that the pubsub subscriber can only receive messages for topics named `neworder` when deployed to a K8s cluster. Any other topic name results in the subscriber not receiving messages.

However, using a local dapr install on my development machine I can use any topic name I want and successfully send and receive messages.

**To Reproduce**

Using `github.com/dapr/go-sdk v1.3.1`

pub.go

```go
package main

import (
"context"
"fmt"

dapr "github.com/dapr/go-sdk/client"
)

func main() {
client, err := dapr.NewClient()
if err != nil {
panic(err)
}
defer client.Close()

data := []byte(`{"hi": "there"}`)

if err := client.PublishEvent(
context.Background(),
"pubsub",
"neworder2",
data,
); err != nil {
panic(err)
}
fmt.Println("data published")
}
```

sub.go

```go
package main

import (
"context"
"log"
"net/http"

"github.com/dapr/go-sdk/service/common"
daprd "github.com/dapr/go-sdk/service/http"
)

var defaultSubscription = &common.Subscription{
PubsubName: "pubsub",
Topic: "neworder2",
Route: "/orders",
}

func main() {
s := daprd.NewService(":8080")

if err := s.AddTopicEventHandler(defaultSubscription, eventHandler); err != nil
{
log.Fatalf("error adding topic subscription: %v", err)
}

if err := s.Start(); err != nil && err != http.ErrServerClosed {
log.Fatalf("error listenning: %v", err)
}
}

func eventHandler(ctx context.Context, e *common.TopicEvent) (retry bool, err error
) {
log.Printf("event - PubsubName: %s, Topic: %s, ID: %s, Data: %s", e.PubsubName,
e.Topic, e.ID, e.Data)
return false, nil
}
```

component k8s yaml:

```yaml
apiVersion: dapr.io/v1alpha1
auth:
secretStore:
kind: Component
metadata:
name: pubsub
spec:
metadata:
- name: redisHost
secretKeyRef:
key:

name:

- name: redisPassword
secretKeyRef:
key:

name:

- name: enableTLS
value: true
type: pubsub.redis
version: v1
```

Deploy the above to a K8s cluster, run the subscriber in sub.go, and then the publisher in pub.go, and see no messages make it to the subscriber. Change the topic name to `neworder`, restart the subscriber, rerun the publisher, see messages make it to the subscriber.

I am running dapr version 1.5.1 in my K8s cluster.

**Expected behavior**

I expected my subscriber to receive messages for any topic name, so long as the publisher and subscriber use the same topic name. This was the behavior in version 1.2.0 of the go-sdk.

Contributor guide

Open the contributing guide

Research direction

Start with the pub.go and sub.go reproducer and the Kubernetes pubsub component YAML, then run the deployment with both `neworder2` and `neworder` topics. Compare the SDK subscription behavior with the Dapr 1.5.1 cluster behavior and verify that matching arbitrary topic names deliver messages to the subscriber without changing the component configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes, redis
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.