Daily mail subscription implementation using Java Spring-boot and Quartz Scheduler

Overview

Daily Mail Subscription Service

POC Implemented using Java Spring-boot and Quartz Scheduler

Working Application

Exposing 3 endpoints

  • /subscription/create
    • Takes an email-address in the request body and subscribes the provided email-address to the daily mail subscription service
    • If subscribed at 11:47pm, the user will recieve a mail every day at the same time i.e 11:47pm via dynamic cron expressions
    • If Already subscribed, EmailAlreadyRegisteredException is thrown
    • A Quartz Trigger is created with the email-address being the identity (so that same email-address can not be subscribed twice) and added to a Quartz job responsible for sending the daily mail when the trigger is fired.
  • /subscription/status/{emailId}
    • Tells if the provided emailId is registered to the daily mail subsription service i.e a trigger with identity same as the email address is scheduled with the created Quartz job
  • /subscription/cancel/{emailId}
    • Unsubscribes the provided emailId from daily mail subscription service if it's registered i.e unschedules the trigger with identity same as the email address from the created Quartz Job

Main classes and working flow

  • DailySubscriptionMailSenderJob.java
    • Implements the Quartz Job interface and overrides execute(JobExecutionContext context) method
    • execute() method will be executed whenever a trigger registered to the job is fired
    • The method extracts the emailId from the JobExecutionContext and uses it to send mail to the user
  • DailyMailSubscriptionTriggerFactory.java
    • has a single generateTrigger() that takes in an emailAddress and returns a trigger for the above created job with identity as the same email-address
    • the created trigger is assigned a dynamic cron expression that will make the trigger fire exactly 24 hours to the current time
  • DailyMailSubscriptionScheduler.java
    • Exposes methods to
      • Start the scheduler and assign the above created Job (Called during application startup by DailyMailSchedulerInitializer.java)
      • Add a new trigger to the scheduler
      • Remove a trigger with the scheduler
      • method returning boolean corresponding to whether trigger with identity same as provided emailId is registered with the scheduler.

Setup

  • Install Java 16
  • Install Maven

Recommended way is to use sdkman for installing both maven and java

Run the below commands in the core

mvn clean
mvn install

Execute any of the two commands below to run the application

java -jar target/daily-mail-quartz-scheduler-spring-boot-0.0.1-SNAPSHOT.jar
mvn spring-boot:run

The Default port is 8080 and base-url is set to /mercury (both can be changed in application.properties)

Go to the below URI to view Swagger-UI (API-docs)

http://localhost:8080/mercury/swagger-ui.html
You might also like...

WordleCompanion - A tool to help you determine those hard-to-guess words while doing your daily Wordle puzzles.

A tool to help you determine those hard-to-guess words while doing your daily Wordle puzzles. How it works Enter the 5-letter word you

Jan 22, 2022

Budget Proof Key for Code Exchange (PKCE) implementation using Java Spring-boot

Low Budget Proof Key for Code Exchange (PKCE) Implementation using Java Spring-boot Just for fun, low budget implementation of PKCE Auth Flow using a

Dec 11, 2022

Spring Boot JdbcTemplate example with SQL Server: CRUD Rest API using Spring Data JDBC, Spring Web MVC

Spring Boot JdbcTemplate example with SQL Server: Build CRUD Rest API Build a Spring Boot CRUD Rest API example that uses Spring Data Jdbc to make CRU

Dec 20, 2022

Two Spring-boot applications registering themselves to an spring-boot-admin-server application as separate clients for the purpose of monitoring and managing the clients

Two Spring-boot applications registering themselves to an spring-boot-admin-server application as separate clients for the purpose of monitoring and managing the clients

Spring-boot-admin implementation with 1 Server and 2 clients Creating a Server application to monitor and manage Spring boot applications (clients) un

Dec 6, 2022

Rate limiting private REST APIs using Java Spring-boot, spring-security and bucket4j

Rate limiting REST APIs using Spring-security filter and Bucket4J Deployed Application (Swagger-ui on heroku) Inspired from: Baeldung Article Applicat

Jul 18, 2022

about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

Spring Boot 学习示例 Spring Boot 使用的各种示例,以最简单、最实用为标准,此开源项目中的每个示例都以最小依赖,最简单为标准,帮助初学者快速掌握 Spring Boot 各组件的使用。 Spring Boot 中文索引 | Spring Cloud学习示例代码 | Spring

Jan 1, 2023

spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。另外写博客,用 OpenWrite。

spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。另外写博客,用 OpenWrite。

推荐工具: 微信公众号 Markdown 编辑器 - OpenWrite:Markdown 微信编辑器是一款专业强大的微信公众平台在线编辑排版工具,提供手机预览功能,让用户在微信图文 、文章、内容排版、文本编辑、素材编辑上更加方便。 - 更多介绍 博客群发平台 一、支持泥瓦匠 Spring Boot

Jan 5, 2023

Spring-Boot-Plus is a easy-to-use, high-speed, high-efficient,feature-rich, open source spring boot scaffolding

Spring-Boot-Plus is a easy-to-use, high-speed, high-efficient,feature-rich, open source spring boot scaffolding

Everyone can develop projects independently, quickly and efficiently! What is spring-boot-plus? A easy-to-use, high-speed, high-efficient, feature-ric

Dec 31, 2022

Spring Boot Migrator (SBM) - a tool for automated code migrations to upgrade or migrate to Spring Boot

Spring Boot Migrator (SBM) - a tool for automated code migrations to upgrade or migrate to Spring Boot

Spring Boot Migrator uses and is compatible to OpenRewrite, a powerful mass refactoring ecosystem for Java and other source code.

Jan 2, 2023
Owner
Java developer working extensively in spring boot and libraries relating to the java ecosystem.
null
Tuya 37 Dec 26, 2022
循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

mrbird 24.8k Jan 6, 2023
Projecto Spring with Quartz

Spring Boot Quartz Scheduler : Building an Email Scheduling Requirements Java - 8 Maven - 3.x.x > MySQL - 5.x.x > Steps to Setup 1. Clone the applicat

jrojast 1 Jan 25, 2022
Search API with spelling correction using ngram-index algorithm: implementation using Java Spring-boot and MySQL ngram full text search index

Search API to handle Spelling-Corrections Based on N-gram index algorithm: using MySQL Ngram Full-Text Parser Sample Screen-Recording Screen.Recording

Hardik Singh Behl 5 Dec 4, 2021
GalaxyCDC is a core component of PolarDB-X which is responsible for global binary log generation, publication and subscription.

中文文档 What is ApsaraDB GalaxyCDC ? GalaxyCDC is a core component of PolarDB-X which is responsible for global binary log generation, publication and su

null 56 Dec 19, 2022
The Spring Boot Sample App on K8S has been implemented using GKE K8S Cluster, Spring Boot, Maven, and Docker.

gke-springboot-sampleapp ?? The Spring Boot Sample App on K8S has been implemented using GKE K8S Cluster, Spring Boot, Maven, and Docker. Usage To be

KYEONGMIN CHO 1 Feb 1, 2022
A plugin of Grasscutter for send in-game mail conveniently

MeaMailPlus - Grasscutter Mail enhancements MeaMailPlus is a plugin of Grasscutter, you can use this plugin to send your mail conveniently. English |

ButterCookies 118 Dec 13, 2022
Envio automatizado de mensagens por e-mail.

Yara - Message in a Bottle Yara é uma aplicação que permite o envio de e-mails automatizados com mensagens pré-formatadas (ou não) a usuários cadastra

NExT 3 Jul 6, 2022
Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example

Spring Boot Login example with Spring Security, MySQL and JWT Appropriate Flow for User Login and Registration with JWT Spring Boot Rest Api Architect

null 58 Jan 5, 2023
A smart personal voice assistant powered by Alan AI. Enjoy hands free application that can manage daily tasks

Todogenix A smart personal voice assistant using Alan AI. Intro Todogenix is a personal assistant app powered by Alan AI that helps store and manage o

Venu Sai Madisetti 8 Mar 15, 2022