Skip to content

Commit

Permalink
EDU-2293: updated to rethrow exception in Workflow fail case
Browse files Browse the repository at this point in the history
  • Loading branch information
fairlydurable committed May 2, 2024
1 parent 80c4add commit 774903e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/java/moneytransfer/MoneyTransferWorkflowImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ public void transfer(TransactionDetails transaction) {
// A recovery mechanism can fail too. Handle any exception
System.out.printf("[%s] Deposit of $%d to account %s failed. Did not compensate withdrawal.\n",
transactionReferenceId, amountToTransfer, destinationAccountId);
System.out.printf("[%s] Workflow failed.", transactionReferenceId);
System.out.flush();
}

System.out.printf("[%s] Ended transaction in inconsistent state.\n",
transactionReferenceId);
System.out.flush();
// Rethrowing the exception causes a Workflow Task failure
throw(e);
}
}
}
// @@@SNIPEND
2 changes: 1 addition & 1 deletion src/main/java/moneytransfer/TransferApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void main(String[] args) throws Exception {
System.out.printf("\nMONEY TRANSFER PROJECT\n\n");
System.out.printf("Initiating transfer of $%d from [Account %s] to [Account %s].\n\n",
amountToTransfer, fromAccount, toAccount);
System.out.printf("[WorkflowID: %s]\n[RunID: %s]\n\n", we.getWorkflowId(), we.getRunId());
System.out.printf("[WorkflowID: %s]\n[RunID: %s]\n[Transaction Reference: %s]\n\n", we.getWorkflowId(), we.getRunId(), referenceId);
System.exit(0);
}
}
Expand Down
Binary file added workflow_input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 774903e

Please sign in to comment.