4 Replies Latest reply on Jul 14, 2010 9:25 PM by Nikolay Elenkov

    Asynchronous methods doesn't run asynchronously :(

    Ilya Dyoshin Novice

      Hello community!

      I'm working on development of several background tasks for my System. Thus I need to create the asynchronous calls:

      here's how I'm doing this using Stateless EJB, the method which triggers this calculation is annotated with @Transactional @TransactionAttribute(REQUIRES_NEW) and @Asynchronous. The method only excepts String parameter of the id (no @Expires, @IntervalCron parameters). When I start using this method in loop - it doesn't makes asynchronous calls :(  the method is invoked one-by-one not as multithreaded asynchronous calls :(   I'm using Quartz with inMemory store (also tried the jdbc store - doesn't helped)

      any idea?

      Ah yeap, the code snippets:

      The main logic

      public interface IRezervCalculator {
           public void polici(Polici p, Date calculationDate);
           public void cache(Polici p);
           public void cache(String idPolici); 

      The scheduler

      public class RezervScheduler {
           Log logger;
           @In(create=true, value="polici.rezerv.calculator")
           IRezervCalculator calculator;
           public void cache(String idPolici) {
                logger.info("scheduling #0 ", idPolici);

      And I'm starting this calculations from the REST-service with something like this:

                      Query q = em.createQuery(.........);
                List<Map<String, Object>> obList = q.getResultList() ;
                for (Map<String, Object> m : obList) {
                     String id = m.get("id").toString();

      Any idea how to make things working in parallel?

      Kind regards,
      Ilya Dyoshin