geraldoyudo / mmadu

This is a user management service that enables developers to focus on writing applications without worrying about where to store user information, user authentication and authorization flows and all that nonsense. This takes care of all that. Mmadu was coined from the igbo word "Mmadu" meaning people.
MIT License
3 stars 2 forks source link

Domain notification event listeners not setup when a domain is configured using the api #147

Closed geraldoyudo closed 4 years ago

geraldoyudo commented 4 years ago

When a domain is configured on the notification service using the /domains api, the event listeners are not setup and because of this, it does not listen to events.

However, when the service is restarted, the event listeners are setup and can now listen to events.

Steps to Reproduce:

  1. Configure a new domain on the notification service
POST /domains HTTP/1.1
Host: localhost:15554
Authorization: Bearer <token>
Content-Type: application/json
Cookie: JSESSIONID=97D5C32F3FB98FC44434D7E9BF70CCB1

[
    {
        "domainId": "test1",
        "profiles": [
            {
                "profileId": "default",
                "rules": [
                    {
                        "expression": "true",
                        "provider": "none",
                        "priority": 1000
                    }
                ]
            }
        ],
        "providerConfigurations": [],
        "userNotificationMessages": [
            {
                "type": "email",
                "eventTriggers": [
                    "user.password.reset.initiation"
                ],
                "messageTemplate": "user.password.reset.initiation.template"
            },
            {
                "type": "email",
                "eventTriggers": [
                    "user.validation.property.email"
                ],
                "messageTemplate": "user.validation.property.email.template",
                "destinationProperty": "propertyName"
            },
            {
                "type": "sms",
                "eventTriggers": [
                    "user.validation.property.sms"
                ],
                "messageTemplate": "user.validation.property.sms.template",
                "destinationProperty": "propertyName"
            }
        ],
        "eventNotificationMessages": []
    }
]
  1. Check RabbitMQ for queue creation.

http://localhost:15672/#/queues

Expected: Two queues are supposed to be created for the domain: UserEventQueue[test1.event.#] and UserEventQueue[test1.user.#]. This shows that the service has started listening to user and generic events. Notification service should listen for events as soon as a domain is configured as above or by creating a domainConfiguration item using the POST /repo/domainConfigurations api.

Actual: These queues are not created. However, when the service is restarted, the queues are created and the service listens for events.