1

I just started with Dapr a few days back and although I am able to publish and subscribe to events in Dapr, the way I am doing so is using the Topic method attribute on an action method within a controller such as this...

enter image description here

And while this works I prefer not to mix integration events with service API. This is the Swagger...

enter image description here

I get that the topic name is long but it's so I can ensure unique topics.

What I'd prefer is to position the Handler outside of any Controller. Something like this..

enter image description here

Is this even possible?

John Kears
  • 677
  • 6
  • 20

1 Answers1

2

I derived a solution out of the .Net Dapr client routing sample.

For each event I add a MapPost endpoint similar to the following

enter image description here

The RequestDelegator receives the event for a given Topic, it will resolve the handler class from the interface and topic attributes and then invoke it's handle method, passing in the event data from Dapr.

enter image description here

My services follow the CQRS and EventSourcing patterns, as such integration events will rarely be the same shape as the command inputs. In my case, events are typically much lighter than a commands, consisting of mostly related Ids.

John Kears
  • 677
  • 6
  • 20