0

i have a function with a fetch query which is run from 2 places - First place its called sequentially which takes 2 secs to run - 2nd place is when @Scheduled job is run , the same query takes 30 secs to run.

Can someone help me with this issue , this is a big performance hit to the application. Does the @Scheduled java functionality pick up a different hibernate session due to which a delay is induced when running the query? @Scheduled function is called every 5secs to pick up a job from DB queue based on which the query is executed

    @Scheduled(fixedDelay = 5*1000)
    @Transactional
    public void dataScheduled() throws MessagingException, IOException, InstanceNotFoundException, AttributeNotFoundException, MalformedObjectNameException, ReflectionException, MBeanException, UnsupportedEncodingException {
    /*some code


    */
    getNotification();
}
    getNotification(){
    //some query
    }
Archana
  • 53
  • 1
  • 9
  • Can you show some code? – lczapski Oct 17 '19 at 06:46
  • Do you check query execution time for example like that: https://stackoverflow.com/a/18204269/11733759 maybe code before `getNotification` is slowe? – lczapski Oct 17 '19 at 07:10
  • i've profiled the application and checked, its exactly the query thats taking time when autoFLush takes place. Thats how the framework is designed. I tried to overwrite flush mode to manual however it overrides to autoflush in the end. however the same code runs totally when its called outside of the @scheduled – Archana Oct 17 '19 at 08:36

0 Answers0