dotnet-sdk icon indicating copy to clipboard operation
dotnet-sdk copied to clipboard

Pubsub name only known at runtime

Open danielgerlag opened this issue 3 years ago • 1 comments

How do I subscribe to a topic where I only know the pubsub name or topic name at runtime? The [Topic] attribute only accepts constants, and cannot be populated with a value from a variable.

danielgerlag avatar Oct 07 '22 18:10 danielgerlag

https://github.com/dapr/dotnet-sdk/blob/master/examples/AspNetCore/ControllerSample/CustomTopicAttribute.cs#L26

saber-wang avatar Oct 08 '22 05:10 saber-wang

You can also use WithTopic like this: https://github.com/dapr/dotnet-sdk/blob/master/examples/AspNetCore/RoutingSample/Startup.cs#L106.

If you need truly programmatic subscriptions, those are not yet supported by Dapr. If you're just loading the name at runtime, this or the above post should work.

halspang avatar Oct 17 '22 17:10 halspang

@danielgerlag - Do you need any more information?

halspang avatar Oct 25 '22 00:10 halspang

Thanks that worked for me... but it was hard to find these examples.

danielgerlag avatar Oct 25 '22 18:10 danielgerlag

@danielgerlag are you looking for examples to Subscribing in the pubsub docs here?

brettveenstra avatar Oct 26 '22 20:10 brettveenstra