0

I have a non-persistent programmatic timer. When the execution is more than 600 seconds, the @Timeout method is launched twice. However if the execution is smaller than 600 seconds it only executes one time.(this is what I need).

Anybody knows what's happening?

How can I solve this problem in order for the timer to only execute one time?

Regards

Apostolos
  • 10,033
  • 5
  • 24
  • 39
  • so you created a timer e.g. `timerService.createIntervalTimer(600000, 600000, config);` and if execution takes more than 600 seconds it doesnt log similar to `A previous execution of timer`...? – Apostolos Jun 13 '18 at 07:50
  • The timer is created as timerService.createIntervalTimer(date, 86400000, new TimerConfig(“timerName”, false). The timer is executed once per day. If the @timeout method takes more than 600 seconds, this method is launched twice (only twice). But if it takes less time, it is launched only once. There is not any log like “A previous execution of timer”. I know the duration because I write a log when the timer start and it’s written twice. Besides I check the JBoss console and there is only this timer and is not persistent. – Angel Ferrando Jun 13 '18 at 10:40

1 Answers1

0

I have already found a way to fix it. Is putting the annotation @timeout the annotations @TransactionAttribute and @TransactionTimeout:

@Timeout
@TransactionAttribute (TransactionAttributeType.REQUIRES_NEW)
@TransactionTimeout (value = 1, unit = TimeUnit.HOURS)

To have those dependencies put in the pom

<dependency>
         <groupId> org.jboss.ejb3 </ groupId>
         <artifactId> jboss-ejb3-ext-api </ artifactId>
         <version> 2.2.0.Final </ version>
   </ dependency>

I help you with these questions: wildfly 10 final: Error invoking timeout for timer (it's for @schedule but it applies the same thing).

https://developer.jboss.org/thread/248773?_sscc=t