timer - Java @Singleton EJB executing method at most every 5 seconds -


hi implementing web application email sending functionality. in order our email server not blacklisted have send @ 1 email per 5 seconds. thinking create @singleton ejb email sender, in way 1 ejb instance responsible sending emails in whole application. how should implement 5 seconds counter in order send @ 1 email per 5 seconds? e.g class that

  @singleton   public class emailsender {        public void sendemail(string msg){                  ....        }   } 

try using @schedule:

@singleton public class emailsender {      queue<email> queue;       @schedule(second = "*/5", minute = "*", hour = "*")      public void sendemail(string msg){           if (!queue.isempty()) {                //get queue element , send email           }      } } 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -