'Can and should a Microservice act like both Publisher and Subscriber?
A Microservice X is subscribed to events from Microservice Y via Azure Event Hub. Now same Microservice X needs to publish different set of events to Microservice Z. We are using Azure Function App, .Net 6.0 and C# as the tech stack. Each service (X, Y and Z) is a separate solution (Visual Studio Solution) encapsulating all its components and implements ACL to map models across domains.
Can and should a Microservice act like a Publisher for one entity and Subscriber for another entity? Will having one Microservice acting both like Publisher and Subscriber slow down future development? Please note we are using Azure Function App.
Azure Function App can have multiple functions separated across respective classes (concerns). What I'm not sure is, in long term, how hard or easy would be to maintain such a service which is acting both as Publisher and Subscriber. Should I've separate Publisher and Subscriber services within the same domain? But then there would a lot of duplicate code. Thanks for your response.
Solution 1:[1]
In azure we have a concept of triggers which are basically are invoked when something happens for example an http request.
Also, you can make http request from an azure function. There are a number of triggers such as http trigger, time trigger (it gets invoked at a particular prespecified time), blob storage trigger, etc.
So, using trigger an azure function can act as a subscriber to an external event ,while it can also make http request, connect to databases, add event grid, etc and thus become a publisher.
refer the following Documation on trigger.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MohitGanorkar-MT |
