Enhanced Version of Email Processing Architecture — Ruby web and mobile app development company in India

Enhancement:

Level 1:

  • Task And Alert service is broken down into two services i.e Task And Alert service and Email Message Service, where Task And Alert service will fetch the ‘00’ records where email has to be shoot out to the user and another Email Process Service will push the event to Internal Event Queue.

Level 2:

  1. Reentrant lock, Implementing Fairness: In a case of synchronized keyword any thread can acquire the lock once released(as preference cannot be specified), whereas in the case of ReentrantLock fairness property is introduced, which provides a lock to longest waiting for a thread, to avoid starvation. Longest waiting for thread Email Manager Thread will get a chance to call get Next Event from Internal Event Queue.
  2. Executor Services: A pool of thread is created which will deal with writing the serializable objects to a directory, whereas Email Manager Thread will fetch the event from Internal Event Queue and will hand-over the further processing to the pool of threads and himself will return to fetch next event.

Mentioned example deals with initializing the thread, when not making use of Executors Services:

Runnable task = () -> { String threadName = Thread.currentThread().getName(); System.out.println(“ThreadName ” + threadName); }; task.run(); Thread thread = new Thread(task); thread.start();

System.out.println(“Finished Working!”);


Originally published at navyuginfo.com on January 11, 2017.