Skip to content

Create Notification Service

Piyush Chaudhari edited this page Aug 19, 2018 · 13 revisions

Create spring boot notification-service project as microservice.
Add below dependencies in your project.

compile('org.springframework.boot:spring-boot-starter-freemarker') for email templating
compile('org.springframework.boot:spring-boot-starter-mail') for send mail via Gmail

Set below property on application.properties

spring.mail.protocol=smtp
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=set your gmail account id
spring.mail.password=set your gmail password
spring.mail.properties.mail.smtp.auth = true
spring.mail.properties.mail.smtp.starttls.enable = true
spring.mail.properties.mail.debug=true

Create template welcom-template.ftl under resources/templates directory

Run spring boot notification service. It will be running on 8088 port.
To send email notification you need user below information:

URL: http://localhost:8088/notification/registration/welcome
Method: POST
Content-Type: application/json
Body: { "to":"[email protected]", "name":"Piyu", "signature":"Notification Team", "location":"Ahmedabad" }