question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Subscribing multiple endpoints to the same Topic not longer supported

See original GitHub issue

Does the Dapr DotNet-SDK supports subscribing multiple endpoints to the same Topic?

I was under the assumption that this basic scenario was obviously supported but I can’t seem to make it work. Seems extremely weird that we can’t subscribe multiple/different endpoints (even in different Controllers) to the same Topic.

Here is the branch with all the code mentioned below: https://github.com/fbridger/dotnet-sdk/tree/pubsub-multiple-subscribers

Trying to subscribe to the same Topic

Example being modified: https://github.com/dapr/dotnet-sdk/tree/master/examples/AspNetCore/ControllerSample

In the ControllerSample (included in dotnet-sdk), I am trying to subscribe multiple endpoints to same Topic but can’t seem to make it work.

I’ve added the following methods in the SampleController.cs

[Topic("pubsub", "deposit")]
[HttpPost("LogDeposit")]
public ActionResult LogDeposit(Transaction transaction)
{
    logger.LogDebug($"Log deposit Id: {transaction.Id} Amount: {transaction.Amount}");
    return NoContent();
}

[Topic("pubsub", "withdraw")]
[HttpPost("LogWithdraw")]
public ActionResult LogWithdraw(Transaction transaction)
{
    logger.LogDebug($"Log withdraw Id: {transaction.Id} Amount: {transaction.Amount}");
    return NoContent();
}

However, when running the app and hitting the /dapr/subscribe those new endpoints are not registered:

[
  {
    "topic": "custom-topic",
    "pubsubName": "custom-pubsub",
    "route": "exampleCustomTopic"
  },
  {
    "topic": "deposit",
    "pubsubName": "pubsub",
    "route": "deposit"
  },
  {
    "topic": "withdraw",
    "pubsubName": "pubsub",
    "routes": {
      "default": "withdraw",
      "rules": [
        {
          "match": "event.type ==\"withdraw.v2\"",
          "path": "withdraw.v2"
        }
      ]
    }
  }

Applications logs:

== APP == fail: DaprTopicSubscription[0]
== APP ==       A default subscription to topic deposit on pubsub pubsub already exists.
== APP == fail: DaprTopicSubscription[0]
== APP ==       A default subscription to topic withdraw on pubsub pubsub already exists.
== APP == fail: DaprTopicSubscription[0]
== APP ==       A default subscription to topic custom-topic on pubsub custom-pubsub already exists.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
fbridgercommented, Sep 11, 2021
1reaction
fbridgercommented, Sep 11, 2021

@pkedy I have confirmed that after the changes you applied in aba49d1446dcd5fa68aa5b8a7597cb6a59e83f88 the /dapr/subscribe is removing Topics with the same Topic and Name but different Route.

Here is the branch where I’ve reverted your changes and added multiple endpoints to subscribe to the same Topic: https://github.com/fbridger/dotnet-sdk/tree/pubsub-multiple-subscribers-before-changes

I’ve reverted your changes and the /dapr/subscribe endpoint respond with the expected result:

// 20210911111320
// http://localhost:5000/dapr/subscribe

[
  {
    "topic": "deposit",
    "pubsubName": "pubsub",
    "route": "deposit"
  },
  {
    "topic": "withdraw",
    "pubsubName": "pubsub",
    "route": "withdraw"
  },
  {
    "topic": "custom-topic",
    "pubsubName": "custom-pubsub",
    "route": "exampleCustomTopic"
  },
  {
    "topic": "deposit",
    "pubsubName": "pubsub",
    "route": "LogDeposit"
  },
  {
    "topic": "withdraw",
    "pubsubName": "pubsub",
    "route": "LogWithdraw"
  }
]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Nservicebus Multiple Endpoints Error
It looks like the host is finding two implementations of EndPointConfig. From the error message, they both seem to be named the same, ......
Read more >
How do I resolve the issue the request matched multiple ...
I'm getting this error when calling any of the methods below. Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched ...
Read more >
Support multi-topic consumer subscriptions · Issue #35
Currently you can only subscribe to one topic because the old consumer only supports making one call to ConsumerConnector.
Read more >
Subscribe - Amazon Simple Notification Service
Subscribes an endpoint to an Amazon SNS topic. If the endpoint type is HTTP/S or email, or if the endpoint and the topic...
Read more >
Adding Subscriptions to Endpoints - Solace
A client can add or remove Topic subscriptions whether it is bound to the Queue or not, but the Queue must have at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found