wildfly 10 final: Error invoking timeout for timer

前端 未结 1 1742
面向向阳花
面向向阳花 2021-01-28 09:15

i have

@Stateless
public class TimerMonitoraggioDatabase {

    @Schedule(hour=\"5\", minute=\"10\", dayOfWeek=\"Mon-Fri\",
      dayOfMonth=\"*\", month=\"*\",         


        
相关标签:
1条回答
  • 2021-01-28 09:54

    I did have the same problem with Wildfly 10.

    Since @Schedule is just a short and easy way to package an implicit EJB Timer with a @Timeout method, all other EJB Timer restrictions apply.

    I am no expert on EJB, but it seems that there is a default timeout, when the @Schedule method is expected to finish - which seems quite short (i.e. mere minutes). Additionally - from empirical evidence - it looks like if the timout is reached, it tries to trigger the method again (hence the second run after the first terminates).

    I read that you can configure the default timeout directly in JBoss, but this was no option for me - so I did not persue this lead (JBoss transaction timeout setting?).

    What I did was setting the timeout for the @Schedule method manually. Since Wildfly 10 is using EJB3 as default, make sure that you use the EJB3 version of the TransactionTimeout annotation.

    If not already implicit, please add the following to your pom.xml:

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

    Now you can set a timout just for your @Schedule method, like:

    import org.jboss.ejb3.annotation.TransactionTimeout:
    
    @Schedule(hour="5", minute="10", dayOfWeek="Mon-Fri",
          dayOfMonth="*", month="*", year="*", info="MyTimer", persistent=false)
    @TransactionTimeout(value = 23, unit = TimeUnit.HOURS)
    private void scheduledTimeout(final Timer t) {
    
    0 讨论(0)
提交回复
热议问题