Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate timer issue #2372

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,20 @@ public static class GlobalJobHandle extends DefaultJobHandle

private static final long serialVersionUID = 510l;

private transient boolean valid;
public GlobalJobHandle(long id) {
super(id);
this.valid = true;
}


public boolean isValid() {
return valid;
}

public void setValid(boolean valid) {
this.valid = valid;
}

public Long getTimerId() {
JobContext ctx = this.getTimerJobInstance().getJobContext();
if (ctx instanceof SelfRemovalJobContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ public void internalSchedule(TimerJobInstance timerJobInstance) {
Timer timer = timerService.createSingleActionTimer(expirationTime, config);
TimerHandle handle = timer.getHandle();
((GlobalJpaTimerJobInstance) timerJobInstance).setTimerInfo(handle);
logger.debug("Timer scheduled {} on {} scheduler service", timerJobInstance);
String timerServiceId = ((EjbGlobalJobHandle) timerJobInstance.getJobHandle()).getDeploymentId();
logger.debug("Timer scheduled {} on {} scheduler service", timerJobInstance, timerServiceId);
((GlobalJpaTimerJobInstance) timerJobInstance).setExternalTimerId(getPlatformTimerId(timer));
if (useLocalCache) {
localCache.putIfAbsent(((EjbGlobalJobHandle) timerJobInstance.getJobHandle()).getUuid(), timerJobInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public boolean removeJob(JobHandle jobHandle) {
// this situation needs to be avoided as it should not happen
return false;
}
((GlobalJobHandle) jobHandle).setValid(false);
JtaTransactionManager tm = (JtaTransactionManager) TransactionManagerFactory.get().newTransactionManager();
try {
tm.registerTransactionSynchronization(new TransactionSynchronization() {
Expand All @@ -117,9 +118,10 @@ public void afterCompletion(int status) {
if (status == TransactionManager.STATUS_COMMITTED) {
logger.debug("remove job {} after commited", jobHandle);
scheduler.removeJob(jobHandle, ejbTimer);
} else {
((GlobalJobHandle) jobHandle).setValid(true);
}
}

});
logger.debug("register tx to remove job {}", jobHandle);
return true;
Expand Down Expand Up @@ -257,8 +259,7 @@ public void setInterceptor(SchedulerServiceInterceptor interceptor) {

@Override
public boolean isValid(GlobalJobHandle jobHandle) {

return true;
return jobHandle.isValid();
}

protected String getJobName(JobContext ctx, long id) {
Expand Down