Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-1122

@Timeout & @TA(NOT_SUPPORTED) methods in @Singleton beans run with transactional context

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 1.6.0
    • 1.7.0
    • None
    • None
    • Windows 7 x64, jdk1.6.0_45 64 bits

    Description

      This component:

      @Singleton
      @Startup
      public class SendSubscriptionsTimer {
      @Inject
      private Logger logger;

      @Resource
      private TimerService timerService;

      @PostConstruct
      private void systemStartup()

      { ScheduleExpression schedule = new ScheduleExpression().second("0").minute("*/1").hour("*"); TimerConfig timerConfig = new TimerConfig(); timerConfig.setPersistent(false); timerService.createCalendarTimer(schedule, timerConfig); }

      @Resource
      private TransactionSynchronizationRegistry tx;

      @Timeout
      @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
      private void timerFired() {
      logger.info("TIMER START");
      logger.info("Transaction: {}", tx.getTransactionKey().toString());
      }
      }

      logs:

      INFO 2014-02-14 13:46:00,025 TIMER START
      INFO 2014-02-14 13:46:00,026 Transaction: [Xid:globalId=5000000047544d4944000000000000000000000000000000000000000000000000000,length=64,branchId=0000000000000000000000000000000000000000000000000000000000000000,length=64]

      Additionally, if this timerFired method performs some lengthy task (in my case duration is 30 minutes), I get this:

      2014-02-14 06.22.41 org.apache.openejb.core.timer.EjbTimerServiceImpl ejbTimeout
      WARNING: Exception occured while completing container transaction
      javax.transaction.RollbackException: Unable to commit: transaction marked for rollback
      at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:272)
      at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:252)
      at org.apache.openejb.core.timer.EjbTimerServiceImpl.ejbTimeout(EjbTimerServiceImpl.java:801)
      at org.apache.openejb.core.timer.EjbTimeoutJob.execute(EjbTimeoutJob.java:39)
      at org.quartz.core.JobRunShell.run(JobRunShell.java:207)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.Exception: Transaction has timed out
      at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:266)
      ... 7 more

      As a result, the @Timeout method gets called the second time (per EJB spec: if exception is thrown, server must retry at least once).

      Attachments

        Activity

          People

            romain.manni-bucau Romain Manni-Bucau
            donatasc Donatas Ciuksys
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: