code: public void execute() throws ActivityException {
          EventWaitInstance received = registerWaitEvents(false, true);
          if (received!=null) {
              setReturnCodeAndExitStatus(received.getCompletionCode());
              processMessage(getExternalEventInstanceDetails(received.getMessageDocumentId()));
              boolean toFinish = handleCompletionCode();
              if (toFinish && exitStatus==null)
                  exitStatus = WorkStatus.STATUS_COMPLETED;
          } else {
              exitStatus = WorkStatus.STATUS_COMPLETED;
              setReturnCode(null);
          }
      }
docs: Method that executes the logic based on the work