Multiple Service Instances in Domain

Posted by acampbelle1 on 03-Jul-2012 12:33

I have a situation where I have a custom java service that creates a timer to perform various duties upon execution. I have the instance of that service in an ESB container. That ESB Container is inside two Containers. There is a primary one and another that is a backup container. I have it this way because I only want the execution duties of this timer happening once per interval, and if the primary goes down the secondary will start up and pick up the execution duties. The issue is that the timer is created in the initialization of the service instance which I have found will start the timer even if the container it is in goes to a standby state. Is there a way when the timer executes for me to check if the container the service instance is in is in standby (or at least not on)? Thanks.

All Replies

Posted by testsoa on 03-Jul-2012 15:39

Adam,

I had the same problem. A solution that works for me"

XQState state = initContext.getLifeCycle().getCurrentServiceState();
if (state != XQState.STARTED) {
     initContext.getLog().logInformation("[TimerServiceType] Task " + task.getName() +

               " not executed, because the service is not in STARTED state (state = " + state + ")");
     return;
}

(initContext is XQInitContext that I get during service initialization)

This works not only when the whole container goes into standby mode (as a member of FT container pair), but also when the administrator stops the timer service using SMC.

Hope this helps,

Pavol

Posted by acampbelle1 on 05-Jul-2012 14:47

That's exactly what I was needing. Did the trick perfectly, thanks Pavol.

This thread is closed