java – How to design a process and use the business rules for sending alerts/notifications

Currently working on designing a process which demands me to send alerts like email notifications to the users which meet a business criteria(we can also call business rules).

I want to make this process more dynamic so any rule can be deleted, modified added on demand(because there are no predefined set of rules and may change time to time) and the process should be able to send alerts on fly.

I have a rough draft in my mind and looking for corrections/changes. My initial approach will be similar to something like:

  • We already have some processes running which are already performing a set of different functions.
  • So I am thinking to apply the rules in that processes and any data which falls under that criteria will be stored in a newly created database (this database will have the toaddress, from, message, subject, description, rule, processName, timestamp, isSentMessage,status etc…) which will be storing the data.
  • And then another program will be continuously running like a scheduler and it will see for the newly added records and send emails accordingly.

The problem with my approach is :- as the business rules may be changing we cannot update the code which may not be efficient.

So I wanted to know if there is any better approach of achieving this or any modifications to this design(anything like adding additional columns, changing the design, modifications etc).

Technologies being used : Java 8, SQL server, Spring, Autosys.

Any suggestions or any other approaches, design are welcome…

UPDATE:

Now I am here with my solution to the above question but still thinking of any alternate so I am posting here what is in my mind.
I am thinking to set up a autosys job which runs on a scehduler basis(using spring) also using groovy scripts which are stored in database.All other process will be sending the binding parameters in a json format where we think that the rules get triggered. Then my new scheduler will look for that records in that table and it knows which rule to be applied and then it uses that particular groovy template to execute the code for that rule and send an email.

(All process will be inserting records to the db and the decision making will be in groovy script whether to send email or not).

So please suggest me whether my thought process is OK or any modifications are required?