====== Notifications ====== ===== Notification Delivery Service ===== The Notification Delivery Service is responsible for queuing notifications and delivering them to the provider’s APIs. This service supports sending Emails, SMS, push notifications and specific notifications to T4NotificationService. ==== How does it work? ==== {{ :api:delivery_service.jpg?400 |}} Our server sends objects to an Azure Service Bus, directing them to their respective queues. Each type of notification has its own dedicated queue. Azure Functions listen to these queues and are responsible for forwarding the messages to their destinations. The Azure queues are configurable, allowing customization of concurrency and retry policies to meet our specific requirements. ==== How to use it? ==== There is one class per type of notification you can send with Delivery Service, the classes are: * EmailNotificationDeliveryService * SMSNotificationDeliveryService * PushNotificationDeliveryService * NotificationBodyDeliveryService There are interfaces for each component, enabling the use of dependency injection in services and facilitating mocking in integration testing. Each class includes two types of constructors: a parameterless constructor that reads configuration from the app.config files, and another constructor that accepts Azure configuration directly, for services that do not use the app.config file. You can find code examples in the repo T4, file T4\System\Components\T4ServerUtil\Notification\DeliveryServices\EmailNotificationDeliveryService.cs this is a Unit Test repository and you can run the examples directly. ==== How to debug it? ==== In Azure you will find a resource group per environment, the available service groups are: * cts-t4-notificationdeliverysvc-test-rg * cts-t4-notificationdeliverysvc-sim-rg * cts-t4-notificationdeliverysvc-live-rg Inside each each resource group you can find the service busses, all of them have dead letter queues to see the notifications that were not deliver due to an error, it also has an applications insights instance to query the execution logs ====== Notification Service ====== This service receives notification objects and handles different types of notifications for the user. Notifications can be sent to this service using the Service Bus, and the service also uses the Service Bus to deliver its notifications. For this purpose, you can use the **NotificationBodyDeliveryService** object inside **T4ServerUtil**. === Usage Example === var service = new NotificationBodyDeliveryService("cts-t4-notificationdeliverysvc-test-rg", "t4-notification-queue", "DeliveryServiceAccessKey", "X7IT4eVDBwUbP2jFHPGA4EalPTcZIiMml+ASbKApPCI="); var x = new AutoliquidationNotificationBody() { FirmID = "2884B215-4A4B-4E9D-A40E-F8212D713E13", AccountID = "53DEADF6-7750-4F89-9B7D-BFEC7370C6D3", Notification = LiquidationNotificationType.MarginViolation, Positions = new List { new AutoliquidationNotificationBody.PositionLiquidation() { MarketID = "", Volume = 10, Side = BuySell.Buy }, new AutoliquidationNotificationBody.PositionLiquidation() { MarketID = "", Volume = 2, Side = BuySell.Sell }, } }; await service.SendNotificationAsync(x);