EJB Timer runs to often in case of Exception

242 Views Asked by At

In my Java EE Application I'm using a Singleton Bean with a @Schedule worker method. It calls a statless Bean that pings a server via Soap. In case the Server is down an EJBException gets thrown. As shown in the Example the Service should run every 6 Minutes, which perfeclty works. But as soon as the pinged Server is down and Exceptions occure the Service runs 1-2 times per minute. Not good for statistiks and monitoring... Can anyone help?

@Startup
@Singleton(name="PingTimerEJB")
public class PingTimerEJB {

    @EJB
    private IService service;

    @Schedule(hour = "*", minute = "*/6", persistent = false)
    public void doWork() {
        try {
            service.ping();
        } catch (final Exception e) {// NOPMD
            //
        }
    }
}

Setup: Java 6, Weblogic 12c, JRE 170_71, EJB 3.1

1

There are 1 best solutions below

0
On

Before call service.ping() you can try to make low level tcp ip connection. For example use ClientSocket class. In this way you will need to store anywhere host and port.