-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sky Ao <[email protected]>
- Loading branch information
Showing
8 changed files
with
215 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...c/main/java/io/dapr/quickstarts/saga/activities/ProcessPaymentCompensatationActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.dapr.quickstarts.saga.activities; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.dapr.quickstarts.saga.models.PaymentRequest; | ||
import io.dapr.workflows.runtime.WorkflowActivityContext; | ||
import io.dapr.workflows.saga.CompensatableWorkflowActivity; | ||
|
||
public class ProcessPaymentCompensatationActivity implements CompensatableWorkflowActivity { | ||
private static Logger logger = LoggerFactory.getLogger(ProcessPaymentCompensatationActivity.class); | ||
|
||
@Override | ||
public Object run(WorkflowActivityContext ctx) { | ||
PaymentRequest input = ctx.getInput(PaymentRequest.class); | ||
|
||
logger.info("Compensating payment for request ID '{}' at ${}", | ||
input.getRequestId(), input.getAmount()); | ||
|
||
// Simulate slow processing | ||
try { | ||
Thread.sleep(1 * 1000); | ||
} catch (InterruptedException e) { | ||
} | ||
|
||
logger.info("Compensated payment for request ID '{}' at ${}", | ||
input.getRequestId(), input.getAmount()); | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.