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

[Fix #3642] Fixing task deadline functionality #3643

Closed
wants to merge 5 commits into from
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 @@ -37,6 +37,7 @@
*
*/
public class DefaultUnitOfWorkManager implements UnitOfWorkManager {
private static final DefaultUnitOfWorkManager instance = new DefaultUnitOfWorkManager(new CollectingUnitOfWorkFactory());
// uses thread local to associate unit of works to execution context/thread
private ThreadLocal<UnitOfWork> currentUnitOfWork = new ThreadLocal<>();
// uses pass through unit of work as fallback if no unit of work has been started
Expand All @@ -48,6 +49,10 @@ public class DefaultUnitOfWorkManager implements UnitOfWorkManager {

private Set<UnitOfWorkEventListener> listeners = new LinkedHashSet<>();

public static DefaultUnitOfWorkManager get() {
return instance;
}

public DefaultUnitOfWorkManager(UnitOfWorkFactory factory) {
super();
this.factory = factory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ protected InternalKogitoWorkItem createWorkItem(WorkItemNode workItemNode) {
protected void addWorkItemListener() {
super.addWorkItemListener();
getProcessInstance().addEventListener(WORK_ITEM_TRANSITION, this, false);
getProcessInstance().addEventListener(TIMER_TRIGGERED_EVENT, this, false);
}

@Override
protected void removeWorkItemListener() {
super.removeWorkItemListener();
getProcessInstance().removeEventListener(WORK_ITEM_TRANSITION, this, false);
getProcessInstance().removeEventListener(TIMER_TRIGGERED_EVENT, this, false);
}

protected String assignWorkItem(InternalKogitoWorkItem workItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.kie.kogito.process.WorkItemHandlerConfig;
import org.kie.kogito.services.identity.NoOpIdentityProvider;
import org.kie.kogito.services.signal.DefaultSignalManagerHub;
import org.kie.kogito.services.uow.CollectingUnitOfWorkFactory;
import org.kie.kogito.services.uow.DefaultUnitOfWorkManager;
import org.kie.kogito.signal.SignalManagerHub;
import org.kie.kogito.uow.UnitOfWorkManager;
Expand Down Expand Up @@ -67,8 +66,7 @@ protected AbstractProcessConfig(
this.workItemHandlerConfig = mergeWorkItemHandler(workItemHandlerConfig, DefaultWorkItemHandlerConfig::new);
this.processEventListenerConfig = merge(processEventListenerConfigs, processEventListeners);
this.unitOfWorkManager = orDefault(unitOfWorkManager,
() -> new DefaultUnitOfWorkManager(
new CollectingUnitOfWorkFactory()));
() -> DefaultUnitOfWorkManager.get());
this.jobsService = orDefault(jobsService, () -> null);
this.versionResolver = orDefault(versionResolver, () -> null);
this.identityProvider = orDefault(identityProvider, NoOpIdentityProvider::new);
Expand Down
2 changes: 1 addition & 1 deletion quarkus/addons/task-notification/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-events-api</artifactId>
<artifactId>kogito-events-core</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.microprofile.reactive.messaging.Emitter;
import org.kie.kogito.event.DataEvent;
import org.kie.kogito.event.EventPublisher;
import org.kie.kogito.event.usertask.UserTaskInstanceDeadlineDataEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -42,7 +43,7 @@ public class NotificationEventPublisher implements EventPublisher {

@Override
public void publish(DataEvent<?> event) {
if (event.getType().startsWith("UserTaskDeadline")) {
if (event instanceof UserTaskInstanceDeadlineDataEvent) {
logger.debug("About to publish event {} to topic {}", event, CHANNEL_NAME);
try {
emitter.send(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.kie.kogito.process.Processes;
import org.kie.kogito.process.version.ProjectVersionProcessVersionResolver;
import org.kie.kogito.services.jobs.impl.InMemoryJobService;
import org.kie.kogito.services.uow.CollectingUnitOfWorkFactory;
import org.kie.kogito.services.uow.DefaultUnitOfWorkManager;
import org.kie.kogito.uow.UnitOfWorkManager;

Expand Down Expand Up @@ -56,7 +55,7 @@ CorrelationService correlationService() {
@DefaultBean
@Produces
UnitOfWorkManager unitOfWorkManager() {
return new DefaultUnitOfWorkManager(new CollectingUnitOfWorkFactory());
return DefaultUnitOfWorkManager.get();
}

@DefaultBean
Expand Down
2 changes: 1 addition & 1 deletion springboot/addons/task-notification/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-events-api</artifactId>
<artifactId>kogito-events-core</artifactId>
</dependency>

<!-- test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.kie.kogito.event.DataEvent;
import org.kie.kogito.event.EventPublisher;
import org.kie.kogito.event.usertask.UserTaskInstanceDeadlineDataEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -42,7 +43,7 @@ public class SpringNotificationEventPublisher implements EventPublisher {

@Override
public void publish(DataEvent<?> event) {
if (event.getType().startsWith("UserTaskDeadline")) {
if (event instanceof UserTaskInstanceDeadlineDataEvent) {
logger.debug("About to publish event {} to Kafka topic {}", event, topic);
try {
emitter.send(topic, event);
Expand Down
Loading