Skip to content

Commit

Permalink
issue #791
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald Oakes committed Jan 6, 2020
1 parent 918a887 commit 3c709d5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ${StandardInvoke}.proc=10
.mdwignore=4
CombiningConsolidator.java=2
Consolidator.java=1
DependenciesFallbackPublish.java=2
DependenciesFallbackPublish.java=3
DependenciesWaitActivity.java=21
ErrorHandlerActivity.kt=2
IdentityRequestMapper.groovy=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,30 @@
import com.centurylink.mdw.annotations.RegisteredService;
import com.centurylink.mdw.common.service.ServiceException;
import com.centurylink.mdw.config.PropertyManager;
import com.centurylink.mdw.constant.JMSDestinationNames;
import com.centurylink.mdw.model.event.EventType;
import com.centurylink.mdw.model.event.InternalEvent;
import com.centurylink.mdw.model.monitor.ScheduledEvent;
import com.centurylink.mdw.model.workflow.Activity;
import com.centurylink.mdw.model.workflow.ActivityInstance;
import com.centurylink.mdw.services.process.ActivityLogger;
import com.centurylink.mdw.startup.StartupService;
import com.centurylink.mdw.util.JMSServices;
import com.centurylink.mdw.util.ServiceLocatorException;
import com.centurylink.mdw.util.log.LoggerUtil;
import com.centurylink.mdw.util.log.StandardLogger;
import com.centurylink.mdw.workflow.activity.event.FallbackProcessor;
import com.centurylink.mdw.workflow.activity.event.WaitActivityFallback;

import javax.jms.JMSException;
import javax.naming.NamingException;
import java.sql.SQLIntegrityConstraintViolationException;

@RegisteredService(value=StartupService.class)
public class DependenciesFallbackPublish extends WaitActivityFallback {

private static StandardLogger logger = LoggerUtil.getStandardLogger();

@Override
public boolean isEnabled() {
return PropertyManager.getBooleanProperty("mdw.dependencies.wait.fallback.enabled", false);
Expand All @@ -45,6 +60,31 @@ public String getImplementor() {
public void process(Activity activity, ActivityInstance activityInstance) throws ServiceException {
FallbackProcessor fallbackProcessor = new FallbackProcessor(activity, activityInstance);
fallbackProcessor.insertNeededEventWaits();
fallbackProcessor.republishEvents();

try {
fallbackProcessor.republishEvents();
}
catch (ServiceException ex) {
if (ex.getCode() == 500 && ex.getCause() != null && ex.getCause().getCause() != null
&& ex.getCause().getCause().getCause() instanceof SQLIntegrityConstraintViolationException) {
// EVENT_INSTANCE might already exist
InternalEvent msg = InternalEvent.
createActivityNotifyMessage(activityInstance, EventType.RESUME, activityInstance.getMasterRequestId(), "FINISH");
String msgId = ScheduledEvent.INTERNAL_EVENT_PREFIX + activityInstance.getId();
try {
JMSServices.getInstance().sendTextMessage(null, JMSDestinationNames.PROCESS_HANDLER_QUEUE,
msg.toXml(), 2, msgId);
String logMsg = "Notified activity instance for pre-existing EVENT_INSTANCE" + activityInstance.getId() + ": " + msgId;
logger.info(logMsg);
ActivityLogger.persist(activityInstance.getProcessInstanceId(), activityInstance.getId(), StandardLogger.LogLevel.INFO, logMsg, null);
}
catch (NamingException | JMSException | ServiceLocatorException nex) {
throw new ServiceException(ServiceException.INTERNAL_ERROR, nex);
}
}
else {
throw ex;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ public int getMinActivityAge() {

private Map<Activity,ScheduledFuture> activitySchedules = new HashMap<>();

/**
* Per cycle, duplicate events will not be processed.
*/
private Map<String,String> uniqueEvents = new HashMap<>();

@Override
final public void onStartup() throws StartupException {
try {
Expand Down

0 comments on commit 3c709d5

Please sign in to comment.