1

I have a Azure Web App that generate different types of notifications. At the moment, every notification is written in a queue. A queue function I call scheduler read the notification and redirect it toward other functions. Each one of those functions generate a type of notification: email, push, sms.

enter image description here

I have different types of notification. For example:

  • new user
  • update user
  • new request
  • update request
  • delete request
  • new quotation
  • purchase quotation ....

Everytime a event is raised from my app I could send different kind of notification. For example, I must send both email and sms when I create a new user. But everytime a new quotation is created I must send all kind of notifications: email, sms and push.

I want to replace my custom "engine" with Azure Event Grid. I am start studying from here, but honestly I do not understand how to apply what I am studing. I think my main problem is I haven't really understood what a topic and a subscription are.

I share with you my partial solution I think is correct:

  1. I create a topic for each "entity" I have in my project domain. I mean a user topic, a request topic, a quotation topic, ...
  2. Then I create a subscription for each topic and event type. So:
    • In the user topic I create 2 subscriptions: one with event type "new" and one with event type "update":enter image description here
    • I make the same for requests and quotations
  3. In the guide I linked above in the concept paragraph I read:

Event subscriptions - The endpoint or built-in mechanism to route events, sometimes to more than one handler. Event handlers - The app or service reacting to the event.

What I understand is that I could have 1 subscription that run for eample more than one function. So I was thinking to have 1 supscription that run the sms function, the email function and the push-notification function. But I don't understand how to call more than one function from one subscription!

Should I create a subscription foreach event type and for each notification type?

enter image description here

I am fear I am complicationg too much the solution, and perhaps I risk I have to create to many subscriptions.

Another solution I was thinking is to create 1 publisher per notification type. So I would have just 3 publisher: 1 for email , 1 for sms and 1 for push. But in this way, every publisher should manage almost all event type and I must be sure that each event type has a unique name. For example I could not have a generic new but I should have a new-quotation and a new-user because my publisher my distinguish the topic that has managed the event.

enter image description here

Honestly, I don't linke any solution I am thinking. How would you build your Event Grid solution ? Any suggestion please?

Thank you.

PS.: I hope is the correct forum.

1 Answer 1

1

Start simple and add complexity as you need it.

  1. Define a few business (not technical) events your business events. Seriously, make a list e.g. user created, user updated, quote created, quote updated. If user updated is too broad, make the events fine grained (only) as needed. You may find that in some cases you need both success and failure events. You may find that some events are higher order e.g. when a quote gets approved vs. funded. Ultimately, this is where you will make or break your design. If this is new to you expect to do this iteratively.

  2. Start with one topic. Add more if/as the value of doing so becomes clear.

  3. Your app is the event source. Publish events to the topic as they occur. Use the event type field to define what the event is. Use the data field to transmit the small amount of data you wish to include in each event.

  4. Create an email listener. Decide which events it cares about. Subscribe to the topic and take appropriate actions as relevant events are received. Ignore the others.

  5. Create SMS and Push listeners. Do the same thing as #4 above for SMS and push.

  6. If/when you realize you are missing an event you want to take some action on, add it and refactor the above as appropriate.

Sit back and enjoy the fruits of your decoupled design.

5
  • Hi Jason, thak you for the answer. I already defined the events. A custom engine which generate notifications exists. But I want to delete it and use a MSFT solution; I just do not understand how to organize subscriptions. By notification type (sms, email, push)? By event-type (new, update, delete, ....) ? I do not like any of the solution I proposed
    – Simone
    Jan 19, 2023 at 12:38
  • @Ciccio I'm trying to provide an answer with both tactical and structural guidance. Help me understand which aspect of this answer is coming up short for you. For example, is one of the numbered items unclear or to vague from your perspective? Jan 20, 2023 at 0:26
  • Hi @Jason, thank you for your time and for the answer. At the moment I solved in this way: My App (the source) -> 1 topic -> 3 Subscriber -> 3 listeners (1 listener per subscriber, it's a technical limit. Either I do not understand something or the doc is wrong.. see point 3 of my post). Than means that I have a 1 listener/subscriber per notification type (sms, email and push)..
    – Simone
    Jan 21, 2023 at 10:25
  • Now I would scale up my solution, and I think it's better my latter option in the post.. I would like to have 1 topic for each "domain entity"... well, I correct myself to be clearer: I would like to have 1 topic for each microservice (1 for users, 1 for quotations, ...). And I thought was better share subscribers among the topics. It seems impossible. 1 subscriber can belong to just 1 topic. I should write the logic of the subscriber for each topic. It's unthinkable. So I believe that I'm building the solution in a wrong way. Perhaps the subscriber should not mapped to the notification types.
    – Simone
    Jan 21, 2023 at 10:26
  • 1
    Have a look at event filtering here: learn.microsoft.com/en-us/azure/event-grid/event-filtering I would want to keep this as simple as possible. If you're struggling please offer a concrete example of another event you feel needs another topic or subscription and what you want to happen when that event fires. Jan 21, 2023 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.