The purpose of this system is to send notifications by Email, SMS, and mobile push. Also, the client can call its endpoints to send notifications or send them via Apache ActiveMQ Queues.
- Email Notification
- SMS Notification
- Mobile push notification
- Schedule notification
- Swagger API Documentation
- Failure Messages
First, Make sure you already installed Apache Maven, Docker, and docker-compose on your environment, then run:
./mvn clean install -Dactivemq=<activemq host> && docker-compose up
If you don't have any ActiveMQ server installed you can skip the test with:
./mvn clean install -DskipTests && docker-compose up
To see the full documentation of the API go to Swagger also, you can try the API from swagger directly
As you can see Notification System is integrated with three other systems:
- Microsoft Exchange for sending E-mail
- System Providers like Vodafone to send SMS
- Firebase to send Mobile push notification
The notification system is using Apache ActiveMQ for receiving messages and schedule messages. If your system has access to Apache ActiveMQ, so we recommend using one of the following queues instead of using REST endpoints for better performance and better message loss.
notification-email
for sending E-mailsnotification-sms
for sending SMSnotification-mobile-push
for sending Mobile push
notification-email-faild
for sending E-mailsnotification-sms-faild
for sending SMSnotification-mobile-push-faild
for sending Mobile push
These Queues used when something goes wrong with the integrations with other systems while sending notifications
As you can see the Notification system has three endpoints for each type of notification, since each type of notification has a different payload.
The reason for adding endpoints is for clients that cannot contact Apache ActiveMQ directly and when a request comes to any of the endpoints, the endpoint validates the request's parameters and sends it to the correct queue Apache ActiveMQ.
- /notifications/email/ for sending E-mails
- /notifications/sms/ for sending SMS
- /notifications/mobile-push/ for sending Mobile push
{ "body": "string", "cc": "string", "from": "string", "subject": "string", "to": "string" }
curl -X POST "http://localhost:8080/notifications/email/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ 'delay': 0, 'email': { 'body': 'Hello', 'cc': 'amawaziny@gmail.com', 'from': 'amawaziny@gmail.com', 'subject': 'Subject', 'to': 'amawaziny@gmail.com' }}"
As you may note there is a parameter called delay this parameter is used to schedule messages, it's a long number of milliseconds.
jmsTemplate.convertAndSend('notification-email', emailPayload);
And, to schedule an email while using queue
jmsTemplate.setDeliveryDelay(30 * 1000);
jmsTemplate.convertAndSend('notification-email', emailPayload);
{ "body": "string", "to": { "locale": "string", "value": "string" } }
curl -X POST "http://localhost:8080/notifications/sms/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ 'delay': 0, 'sms': { 'body': 'sms', 'to': { 'locale': 'EG', 'value': '01003009331' } }}"
As you may note there is a parameter called delay this parameter is used to schedule messages, it's a long number of milliseconds.
jmsTemplate.convertAndSend('notification-sms', smsPayload);
And, to schedule an SMS message while using queue
jmsTemplate.setDeliveryDelay(30 * 1000);
jmsTemplate.convertAndSend('notification-sms', smsPayload);
{ "body": "string", "deviceId": "string", "os": "string" (ANDROID, IOS, BOTH) }
curl -X POST "http://localhost:8080/notifications/mobile-push/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ 'delay': 0, 'mobilePush': { 'body': 'string', 'deviceId': 'string', 'os': 'ANDROID' }}"
As you may note there is a parameter called delay this parameter is used to schedule messages, it's a long number of milliseconds. Also, deviceId is optional if you want to send it to a specific user then use it.
jmsTemplate.convertAndSend('notification-mobile-push', mobilePushPayload);
And, to schedule a mobile push message while using queue
jmsTemplate.setDeliveryDelay(30 * 1000);
jmsTemplate.convertAndSend('notification-mobile-push', mobilePushPayload);