asynchronous - Calling @Async method from method which is @Schedule -


i have scheduler listens queue (priorityqueue not mq/jms) @ every 1 second, once got message interested in want perform logic.

so have scheduler runs every second, calling method annotated @async, assuming once call method scheduler running interval.

below sample code, not sure using right pattern or advise. idea once have message should not wait prev processing, , can have multiple threads processing it.

i using spring boot.

@scheduled(fixeddelaystring = "1000", initialdelay = 10000) public void startscheduler() {     message msg = queue.peek();     if(msg!=null){       doprocessing(msg);    }  }   @async public void doprocessing(message msg){ // processing // may take 5 seconds. }    


Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -