title: AWS Simple workflow notification technique
body: <p>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 <code>Settable&lt;Boolean&gt;</code> as my flag but the value is not reliable because the workflow is running async. Here's my code:</p>
  
  <pre><code> final AsyncExecutor asyncExecutor = new AsyncRetryingExecutor(retryPolicy, workflowClock);
   final Settable&lt;Boolean&gt; notifyException = new Settable&lt;&gt;();
  
      new TryCatch() {
          @Override
          protected void doTry() throws Throwable {
              asyncExecutor.execute(() -&gt; new TryCatch() {
                  @Override
                  protected void doTry() throws Throwable {
                      Promise&lt;ActivityOne&gt; 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("======");
          }
      };
  </code></pre>
  
  <p>The <code>notifyException</code> 's value is always changing even though I explicitly set its value to <code>true</code> inside <code>if statement</code>. The result of my code is it will perform more than 1 the <code>notification service</code>.</p>
  
  <p>====UPDATE===</p>
  
  <pre><code> final AsyncExecutor asyncExecutor = new AsyncRetryingExecutor(retryPolicy, workflowClock);
   final Settable&lt;Boolean&gt; notifyException = new Settable&lt;&gt;();
  
      new TryCatch() {
          @Override
          protected void doTry() throws Throwable {
              asyncExecutor.execute(() -&gt; new TryCatch() {
                  @Override
                  protected void doTry() throws Throwable {
                      Promise&lt;ActivityOne&gt; activityOne = activityOneClient.performAction(activityOneRequest);
                  }
  
                  @Override
                  protected void doCatch(Throwable e) throws Throwable {
                      if (!notifyException.isReady()) {
                          activityOneClient.notify();
                          notifyException.set(true);
                      }
                      throw e;
                  }
              });
          }
  
          @Override
          protected void doCatch(Throwable e) throws Throwable {
              System.out.println("======");
              System.out.println("CATCH ALL!! " + e.getMessage());
              System.out.println("======");
          }
      };
  </code></pre>
  
  <p>When I re-throw the exception, the <code>activityOneClient.notify()</code> will only be executed on the last retry of <code>asyncExecutor</code>, so if I dont re-throw, the <code>activityOneClient.notify()</code> will be executed automatically. I just need to notify if an exception occur for the first time.</p>