IDEMPIERE-4451 Executions.schedule should be executed asynchronously (#266)
onpiggyback should check whether's there's pending serverpush echo
This commit is contained in:
parent
4c1ba12a3f
commit
98ab98b28c
|
@ -48,7 +48,9 @@ import org.zkoss.zk.ui.util.Clients;
|
|||
*/
|
||||
public class AtmosphereServerPush implements ServerPush {
|
||||
|
||||
private static final String ON_ACTIVATE_DESKTOP = "onActivateDesktop";
|
||||
private static final String ATMOSPHERE_SERVER_PUSH_ECHO = "AtmosphereServerPush.Echo";
|
||||
|
||||
private static final String ON_ACTIVATE_DESKTOP = "onActivateDesktop";
|
||||
|
||||
public static final int DEFAULT_TIMEOUT = 1000 * 60 * 2;
|
||||
|
||||
|
@ -161,7 +163,12 @@ public class AtmosphereServerPush implements ServerPush {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onPiggyback() {
|
||||
public void onPiggyback() {
|
||||
if (Executions.getCurrent() != null && Executions.getCurrent().getAttribute(ATMOSPHERE_SERVER_PUSH_ECHO) != null) {
|
||||
//has pending serverpush echo, wait for next execution piggyback trigger by the pending serverpush echo
|
||||
return;
|
||||
}
|
||||
|
||||
Schedule<Event>[] pendings = null;
|
||||
synchronized (schedules) {
|
||||
if (!schedules.isEmpty()) {
|
||||
|
@ -195,8 +202,8 @@ public class AtmosphereServerPush implements ServerPush {
|
|||
synchronized (schedules) {
|
||||
schedules.add(new Schedule(task, event, scheduler));
|
||||
}
|
||||
if (Executions.getCurrent().getAttribute("AtmosphereServerPush.Echo") == null) {
|
||||
Executions.getCurrent().setAttribute("AtmosphereServerPush.Echo", Boolean.TRUE);
|
||||
if (Executions.getCurrent().getAttribute(ATMOSPHERE_SERVER_PUSH_ECHO) == null) {
|
||||
Executions.getCurrent().setAttribute(ATMOSPHERE_SERVER_PUSH_ECHO, Boolean.TRUE);
|
||||
Clients.response(new AuEcho());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,9 @@ import org.zkoss.zk.ui.util.Clients;
|
|||
*/
|
||||
public class WebSocketServerPush implements ServerPush {
|
||||
|
||||
private static final String ON_ACTIVATE_DESKTOP = "onActivateDesktop";
|
||||
private static final String ATMOSPHERE_SERVER_PUSH_ECHO = "AtmosphereServerPush.Echo";
|
||||
|
||||
private static final String ON_ACTIVATE_DESKTOP = "onActivateDesktop";
|
||||
|
||||
private final AtomicReference<Desktop> desktop = new AtomicReference<Desktop>();
|
||||
|
||||
|
@ -168,6 +170,11 @@ public class WebSocketServerPush implements ServerPush {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onPiggyback() {
|
||||
if (Executions.getCurrent() != null && Executions.getCurrent().getAttribute(ATMOSPHERE_SERVER_PUSH_ECHO) != null) {
|
||||
//has pending serverpush echo, wait for next execution piggyback trigger by the pending serverpush echo
|
||||
return;
|
||||
}
|
||||
|
||||
Schedule<Event>[] pendings = null;
|
||||
synchronized (schedules) {
|
||||
if (!schedules.isEmpty()) {
|
||||
|
@ -208,8 +215,8 @@ public class WebSocketServerPush implements ServerPush {
|
|||
synchronized (schedules) {
|
||||
schedules.add(new Schedule(task, event, scheduler));
|
||||
}
|
||||
if (Executions.getCurrent().getAttribute("AtmosphereServerPush.Echo") == null) {
|
||||
Executions.getCurrent().setAttribute("AtmosphereServerPush.Echo", Boolean.TRUE);
|
||||
if (Executions.getCurrent().getAttribute(ATMOSPHERE_SERVER_PUSH_ECHO) == null) {
|
||||
Executions.getCurrent().setAttribute(ATMOSPHERE_SERVER_PUSH_ECHO, Boolean.TRUE);
|
||||
Clients.response(new AuEcho());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue