I'm new to AWS SWF and my task is to give notification(thru email) when an activity fails during first attempt ONLY. I'm using Settable<Boolean>
as my flag but the value is not reliable because the workflow is running async. Here's my code:
final AsyncExecutor asyncExecutor = new AsyncRetryingExecutor(retryPolicy, workflowClock);
final Settable<Boolean> notifyException = new Settable<>();
new TryCatch() {
@Override
protected void doTry() throws Throwable {
asyncExecutor.execute(() -> new TryCatch() {
@Override
protected void doTry() throws Throwable {
Promise<ActivityOne> activityOne = activityOneClient.performAction(activityOneRequest);
}
@Override
protected void doCatch(Throwable e) throws Throwable {
if (!notifyException.isReady()) {
// PERFORM notification service here!!
notifyException.set(true);
} else {
// DO NOTHING. Notification is already sent the first time :)
}
throw e;
}
});
}
@Override
protected void doCatch(Throwable e) throws Throwable {
System.out.println("======");
System.out.println("CATCH ALL!! " + e.getMessage());
System.out.println("======");
}
};
The notifyException
's value is always changing even though I explicitly set its value to true
inside if statement
. The result of my code is it will perform more than 1 the notification service
.
Aucun commentaire:
Enregistrer un commentaire