Skip to content

Commit

Permalink
DROOLS-733 - unification of execution servers - allow to use jms/ejb …
Browse files Browse the repository at this point in the history
…timers and executors in all supported containers
  • Loading branch information
mswiderski committed Aug 28, 2015
1 parent eaf0670 commit 47ed295
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class ExecutorImpl implements Executor {
private boolean useJMS = Boolean.parseBoolean(System.getProperty("org.kie.executor.jms", "true"));
private String connectionFactoryName = System.getProperty("org.kie.executor.jms.cf", "java:/JmsXA");
private String queueName = System.getProperty("org.kie.executor.jms.queue", "queue/KIE.EXECUTOR");
private boolean transacted = Boolean.parseBoolean(System.getProperty("org.kie.executor.jms.transacted", "false"));
private ConnectionFactory connectionFactory;
private Queue queue;

Expand Down Expand Up @@ -375,10 +376,13 @@ protected void sendMessage(String messageBody) {
MessageProducer producer = null;
try {
queueConnection = connectionFactory.createConnection();
queueSession = queueConnection.createSession(true, Session.AUTO_ACKNOWLEDGE);
queueSession = queueConnection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);

TextMessage message = queueSession.createTextMessage(messageBody);
producer = queueSession.createProducer(queue);
producer = queueSession.createProducer(queue);

queueConnection.start();

producer.send(message);
} catch (Exception e) {
throw new RuntimeException("Error when sending JMS message with executor job request", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.drools.core.time.JobHandle;
import org.drools.core.time.impl.TimerJobInstance;
import org.jbpm.process.core.timer.TimerServiceRegistry;
import org.jbpm.process.core.timer.impl.GlobalTimerService.GlobalJobHandle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -94,25 +93,6 @@ public void internalSchedule(TimerJobInstance timerJobInstance) {
}
}

public boolean isValid(GlobalJobHandle jobHandle) {
EjbGlobalJobHandle ejbHandle = (EjbGlobalJobHandle) jobHandle;

for (Timer timer : timerService.getTimers()) {
Serializable info = timer.getInfo();
if (info instanceof EjbTimerJob) {
EjbTimerJob job = (EjbTimerJob) info;

EjbGlobalJobHandle handle = (EjbGlobalJobHandle) job.getTimerJobInstance().getJobHandle();
if (handle.getUuid().equals(ejbHandle.getUuid())) {
logger.debug("Job handle {} does match timer", jobHandle);
return true;
}
}
}
logger.debug("Job handle {} is not valid on {} scheduler service", jobHandle, this);
return false;
}

public boolean removeJob(JobHandle jobHandle) {
EjbGlobalJobHandle ejbHandle = (EjbGlobalJobHandle) jobHandle;

Expand All @@ -124,7 +104,12 @@ public boolean removeJob(JobHandle jobHandle) {
EjbGlobalJobHandle handle = (EjbGlobalJobHandle) job.getTimerJobInstance().getJobHandle();
if (handle.getUuid().equals(ejbHandle.getUuid())) {
logger.debug("Job handle {} does match timer and is going to be canceled", jobHandle);
timer.cancel();
try {
timer.cancel();
} catch (Throwable e) {
logger.debug("Timer cancel error due to {}", e.getMessage());
return false;
}
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public void setInterceptor(SchedulerServiceInterceptor interceptor) {

@Override
public boolean isValid(GlobalJobHandle jobHandle) {
return scheduler.isValid(jobHandle);

return true;
}

private String getJobName(JobContext ctx, Long id) {
Expand Down

0 comments on commit 47ed295

Please sign in to comment.