Skip to content
Advertisement

Java Scheduler to Mail

Given that I have two scheduled component classes uploading files respectively. I created a sending email method for each of them in order to send a reminder email to myself in case any uploading exceptions happened.

the flow like this:

Scheduler One — if exception during uploading —> sending a email after exception

Scheduler Two — if exception during uploading —> sending a email after exception

now I want to upgrade as

Scheduler One + Scheduler Two –if exception–> sending a mail after two scheduler

Nonetheless, how can I do that?

Advertisement

Answer

You use case sounds really odd. Schedulers run independent. So if you want to share information (an exception was thrown) between both thos you have to store this information somewhere. A entry in a database or saving in in a global variable during runtime.

I would however suggest that you merge both of you scheduler into one. If they are not independent why divide the code? It saves you from creating theses hacks where the schedulers need to be connected

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement