I have 2 different actions and I'm getting responses to those 2 actions at the same time, from the same host.
I want to delay one action for 30 seconds.
I tried using Thread.sleep(30000) but, it seems to delay both the actions.
Both actions are background processes, hence I cannot use the ExecuteAndWaitInterceptor.
Below is ths action that I want to delay.
@Namespace(StrutsConstants.Namespace.PUBLIC)
public class CCAveDNHandlerAction extends BaseRequestResponseAwareAction {
private static Log log = LogFactory.getLog(CCAveDNHandlerAction.class);
public String execute() throws ModuleException {
log.info("CCAveDNHandlerAction ### Starting..");
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Struts2 documentation says that 2 different requests are executed in 2 different threads.
But in this scenario it is not happening. May be because the 2 requests are coming from the same host. Is there a way to force an action to get executed in a separate context ?
Here is the work flow.
Thread.sleep for this action and the whole process is paused.You can use Timer and do TimerTask definitions calling your actions. Then all you need to do is basically do a schedule for each timertask to be invoked and therefore invoke your action.
More on this in the javadoc@ http://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html
GL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With