Skip to content
Merged
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 @@ -85,7 +85,6 @@ private ResponseEntity<String> startWorkflow(String id, MyResourcePut params) {
WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE)
.build();
var workflowStub = temporalClient.newWorkflowStub(MyWorkflow.class, options);
workflowStub.execute();
var wfArgs = new StartMyWorkflowRequest(params.id(), params.value());
// Start the workflow execution.
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
package io.temporal.app.domain.orchestrations;

import io.temporal.app.domain.messages.orchestrations.StartMyWorkflowRequest;
import io.temporal.workflow.Workflow;

public class MyWorkflowImpl implements MyWorkflow {
@Override
public void execute(StartMyWorkflowRequest args) {}
public void execute(StartMyWorkflowRequest args) {
Workflow.await(Workflow::isEveryHandlerFinished);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
import javax.annotation.Nullable;
import org.slf4j.Logger;

// EntityOnboardingImpl is always the `latest` implementation of `EntityOnboarding`
// Versions being superceded will be copied to a separate file (or package), incremented by
// The format {WorkflowInterface}V{previousVersion + 1}Impl
// example:
// 1. The version before `latest` is `EntityOnboardingV99Impl` version
// 2. Copy current `latest` EntityOnboardingImpl as `EntityOnboardingV100Impl`
// 3. Make changes in the existing `EntityOnboardingImpl` with appropriate GetVersion calls
public class EntityOnboardingImpl implements EntityOnboarding {
Logger logger = Workflow.getLogger(EntityOnboardingImpl.class);
private EntityOnboardingState state;
Expand All @@ -72,6 +79,7 @@ public class EntityOnboardingImpl implements EntityOnboarding {
public EntityOnboardingImpl(@Nullable OnboardEntityRequest args) {
// Initialize the state object with
// a non null object in the event of signal/update arriving soon
// See https://docs.temporal.io/handling-messages for details
init(args);
}

Expand Down Expand Up @@ -122,13 +130,16 @@ public void execute(OnboardEntityRequest args) {
args.completionTimeoutSeconds() - waitApprovalSecs,
null,
false);
// be sure to check that all handlers have been completed before CAN
Workflow.await(Workflow::isEveryHandlerFinished);
can.execute(canArgs);
return;
}
}

// make sure we are APPROVED to proceed with the Onboarding
if (!state.approval().approvalStatus().equals(ApprovalStatus.APPROVED)) {
Workflow.await(Workflow::isEveryHandlerFinished);
logger.info("Entity was rejected for {}", args.id());
return;
}
Expand All @@ -146,6 +157,9 @@ public void execute(OnboardEntityRequest args) {
}
throw e;
}
// be sure to check that all handlers have been completed before exit
Workflow.await(Workflow::isEveryHandlerFinished);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public void givenValidArgsWithOwnerApprovalNoDeputyOwner_whenApproved_itShouldBe
.map(Worker::getTaskQueue)
.filter(s -> s.startsWith("replay_"))
.toList();
// enumerate the replay task queues since these have the various `EntityOnboarding` Workflow
// definitions
// These are our "source" Workflows that produce the history to verify against the `latest`
// implementation
for (String tq : taskQueues) {
String wfId = UUID.randomUUID().toString();
String wfId2 = UUID.randomUUID().toString();
Expand All @@ -103,6 +107,7 @@ public void givenValidArgsWithOwnerApprovalNoDeputyOwner_whenApproved_itShouldBe
source.approve(new ApproveEntityRequest("nocomment"));
testWorkflowEnvironment.sleep(Duration.ofSeconds(1));
Assertions.assertDoesNotThrow(() -> source.execute(args));

var history = workflowClient.fetchHistory(args.id());
Assertions.assertDoesNotThrow(
() -> {
Expand Down