2 Replies Latest reply on Jan 16, 2010 4:45 AM by Nikolay Elenkov

    Nested Asynchronous Tasks

    Johannes Hollerer Newbie

      Hi,


      I have a lot of Background Tasks to be completed and therefore i want one instance to monitor all those Background Tasks!
      The monitoring Task is itself contains a @Asynchronous method !


      All is started by using Quartz !


      Within the MainBackgroundTask i then want to launch all the other Background tasks - which listen for external informations.


      My problem now is that the nested Tasks (which are started by the MainBackgroundTasks) do not get the EntityManager to insert the new information into the database.


      The MainBackgroundTask gets the EntityManager (as i read out of the Database which task to start) - and both Functions (which are triggered by Quartz) are configured the same - why is the nested Background task not getting the EntityManager  (its null) !


      The only difference between the MainBackgroundTask and the sub tasks is that the MainBackgroundTask is annotated with


      @Scope(ScopeType.APPLICATION)






          @Asynchronous
          @Transactional
          public QuartzTriggerHandle doMyJob(@IntervalDuration Long interval,int backgroundid){
             ..... getting my infos - and persist them ....
          }




      Can someone explain to me - why i do not get the EntityManager in that case - i cant make the sub's also ScopeType.Application??