1 Reply Latest reply on Nov 29, 2016 2:11 AM by sharkbite

    @AccessTimeout does not work in wildfly-10.0.0.Final

    sharkbite

      Hi

       

      I am trying to get two or more threads waiting to access a singleton method to either:

       

      1. block indefinitely until forward progress  can proceed.

      It blocks thread 2, but when Thread 1 is done, thread 2 does not resume(i.e. step 3 below does not resume). why?

      2. concurrent access is not permitted.

      It throws javax.ejb.ConcurrentAccessTimeoutException but I cannot get Thread 2 to rollback(i.e. step 3 below does not rollback). why?

       

      Here is some code to give perspective to my problem:

       

      @Singleton

      @LocalBean

      @Lock(WRITE) // means only one thread can access this at a time

      @AccessTimeout(-1) // block indefinitely until forward progress it can proceed.

      // @AccessTimeout(value = 100000) // 420000 7 minutes

      // runn

      // A value of -1 indicates that the client request will block indefinitely until

      // forward progress it can proceed.

      // 600000 10 mins

      // https://docs.oracle.com/javaee/7/api/javax/ejb/AccessTimeout.html

      public class NumberComponent {

        /**

        * Generates a list of Numbers

        *

        * @throws NumberGenerationException

        */

        @Lock(WRITE)

        public Collection<Tca01Cards> generateNumbers(…EntityManager em) throws NumberGenerationException {

       

       

        }

      }

       

      @Stateless

      @LocalBean

      public class Thread2Component  {

       

       

        @EJB

        NumberComponent numberComponent;

       

       

        @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

        public void processUploads() {

       

       

        for (Requests request : RequestsList) {

       

       

        processRequest(requests);

        }

       

       

        }

       

       

        @Transactional(rollbackOn={NumberGenerationException.class}

        private void processRequest(Requests request) {

        try {

       

       

       

        //step 1

        //step 2

        //step 3 - do some inserts into db

        //step 4

        numberComponent. generateNumbers(…);

       

        } catch (Exception ex) {

        ex.printStackTrace();

       

       

        }

        }

      }

       

       

        • 1. Re: @AccessTimeout does not work in wildfly-10.0.0.Final
          sharkbite

          Can anyone perhaps point to example that will help me achieve at least one of the following? 

           

           

          1. block indefinitely until forward progress  can proceed.

          It blocks thread 2, but when Thread 1 is done, thread 2 does not resume(i.e. step 3 below does not resume).

          2. concurrent access is not permitted.

          It throws javax.ejb.ConcurrentAccessTimeoutException but I cannot get Thread 2 to rollback(i.e. step 3 below does not rollback).