Class WorkflowUnsafe


  • public final class WorkflowUnsafe
    extends java.lang.Object
    While Workflow contains methods exposing the main Temporal Workflow API that is safe to use by majority of our users, this class contains the part of the Workflow API that is discouraged to be used without careful consideration. While APIs in this class may be required for some legitimate scenarios, most users shouldn't be using them. Relying on these methods without careful consideration and understanding of limitations of each method may lead to an unexpected behavior and mistakes.

    Please reference a documentation for each specific method for more context why this method is considered unsafe to be a part of the main Workflow API.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isReplaying()
      Warning!
      Never make workflow logic depend on this flag as it is going to break determinism.
      static boolean isWorkflowThread()
      Warning!
      The only reasonable usage for this method is writing a library code that has to be used in both workflow and non-workflow code (like an Activity or non-Temporal codebase).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isWorkflowThread

        public static boolean isWorkflowThread()
        Warning!
        The only reasonable usage for this method is writing a library code that has to be used in both workflow and non-workflow code (like an Activity or non-Temporal codebase). This usage is generally discouraged, because mixing of workflow and non-workflow code is error-prone, because workflow code requires considerations for determinism. Writing shared code that is designed to be called from both workflow and non-workflow context may lead to leaking of the code not written with Workflow limitations in mind into Workflow method implementation leading to non-deterministic Workflow implementations.
        Returns:
        true if the current execution happens as a part of workflow method and in a workflow thread context.
      • isReplaying

        public static boolean isReplaying()
        Warning!
        Never make workflow logic depend on this flag as it is going to break determinism. The only reasonable uses for this flag is deduping external never failing side effects like logging or metric reporting.
        Returns:
        true if workflow code is being replayed. This method always returns false if called from a non workflow thread.