Bug: Subscribing multiple endpoints to the same Topic not longer supported
See original GitHub issueDoes 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:
- Created 2 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
Top GitHub Comments
I’ve added a Test to be able to reproduce this error: https://github.com/fbridger/dotnet-sdk/commit/7194de11c76c5c0caac07731e1092f039f9fcb02
@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: