Interface WorkflowStub

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void cancel()
      Request cancellation of a workflow execution.
      static <T> WorkflowStub fromTyped​(T typed)
      Extracts untyped WorkflowStub from a typed workflow stub created through WorkflowClient.newWorkflowStub(Class, WorkflowOptions).
      io.temporal.api.common.v1.WorkflowExecution getExecution()  
      java.util.Optional<WorkflowOptions> getOptions()  
      <R> R getResult​(long timeout, java.util.concurrent.TimeUnit unit, java.lang.Class<R> resultClass)
      Returns workflow result potentially waiting for workflow to complete.
      <R> R getResult​(long timeout, java.util.concurrent.TimeUnit unit, java.lang.Class<R> resultClass, java.lang.reflect.Type resultType)
      Returns workflow result potentially waiting for workflow to complete.
      <R> R getResult​(java.lang.Class<R> resultClass)
      Returns workflow result potentially waiting for workflow to complete.
      <R> R getResult​(java.lang.Class<R> resultClass, java.lang.reflect.Type resultType)
      Returns workflow result potentially waiting for workflow to complete.
      <R> java.util.concurrent.CompletableFuture<R> getResultAsync​(long timeout, java.util.concurrent.TimeUnit unit, java.lang.Class<R> resultClass)  
      <R> java.util.concurrent.CompletableFuture<R> getResultAsync​(long timeout, java.util.concurrent.TimeUnit unit, java.lang.Class<R> resultClass, java.lang.reflect.Type resultType)  
      <R> java.util.concurrent.CompletableFuture<R> getResultAsync​(java.lang.Class<R> resultClass)  
      <R> java.util.concurrent.CompletableFuture<R> getResultAsync​(java.lang.Class<R> resultClass, java.lang.reflect.Type resultType)  
      java.util.Optional<java.lang.String> getWorkflowType()  
      <R> R query​(java.lang.String queryType, java.lang.Class<R> resultClass, java.lang.Object... args)
      Synchronously queries workflow by invoking its query handler.
      <R> R query​(java.lang.String queryType, java.lang.Class<R> resultClass, java.lang.reflect.Type resultType, java.lang.Object... args)  
      void signal​(java.lang.String signalName, java.lang.Object... args)  
      io.temporal.api.common.v1.WorkflowExecution signalWithStart​(java.lang.String signalName, java.lang.Object[] signalArgs, java.lang.Object[] startArgs)  
      io.temporal.api.common.v1.WorkflowExecution start​(java.lang.Object... args)  
      void terminate​(java.lang.String reason, java.lang.Object... details)
      Terminates a workflow execution.
    • Method Detail

      • fromTyped

        static <T> WorkflowStub fromTyped​(T typed)
        Extracts untyped WorkflowStub from a typed workflow stub created through WorkflowClient.newWorkflowStub(Class, WorkflowOptions).
        Type Parameters:
        T - type of the workflow stub interface
        Parameters:
        typed - typed workflow stub
        Returns:
        untyped workflow stub for the same workflow instance
      • signal

        void signal​(java.lang.String signalName,
                    java.lang.Object... args)
      • start

        io.temporal.api.common.v1.WorkflowExecution start​(java.lang.Object... args)
      • signalWithStart

        io.temporal.api.common.v1.WorkflowExecution signalWithStart​(java.lang.String signalName,
                                                                    java.lang.Object[] signalArgs,
                                                                    java.lang.Object[] startArgs)
      • getWorkflowType

        java.util.Optional<java.lang.String> getWorkflowType()
      • getExecution

        io.temporal.api.common.v1.WorkflowExecution getExecution()
      • getResult

        <R> R getResult​(java.lang.Class<R> resultClass,
                        java.lang.reflect.Type resultType)
        Returns workflow result potentially waiting for workflow to complete. Behind the scene this call performs long poll on Temporal service waiting for workflow completion notification.
        Type Parameters:
        R - type of the workflow return value
        Parameters:
        resultClass - class of the workflow return value
        resultType - type of the workflow return value. Differs from resultClass for generic types.
        Returns:
        workflow return value
      • getResultAsync

        <R> java.util.concurrent.CompletableFuture<R> getResultAsync​(java.lang.Class<R> resultClass,
                                                                     java.lang.reflect.Type resultType)
      • getResult

        <R> R getResult​(java.lang.Class<R> resultClass)
        Returns workflow result potentially waiting for workflow to complete. Behind the scene this call performs long poll on Temporal service waiting for workflow completion notification.
        Type Parameters:
        R - type of the workflow return value
        Parameters:
        resultClass - class of the workflow return value
        Returns:
        workflow return value
      • getResultAsync

        <R> java.util.concurrent.CompletableFuture<R> getResultAsync​(java.lang.Class<R> resultClass)
      • getResult

        <R> R getResult​(long timeout,
                        java.util.concurrent.TimeUnit unit,
                        java.lang.Class<R> resultClass,
                        java.lang.reflect.Type resultType)
                 throws java.util.concurrent.TimeoutException
        Returns workflow result potentially waiting for workflow to complete. Behind the scene this call performs long poll on Temporal service waiting for workflow completion notification.
        Type Parameters:
        R - type of the workflow return value
        Parameters:
        timeout - maximum time to wait
        unit - unit of timeout
        resultClass - class of the workflow return value
        resultType - type of the workflow return value. Differs from resultClass for generic
        Returns:
        workflow return value
        Throws:
        java.util.concurrent.TimeoutException - if workflow is not completed after the timeout time.
      • getResult

        <R> R getResult​(long timeout,
                        java.util.concurrent.TimeUnit unit,
                        java.lang.Class<R> resultClass)
                 throws java.util.concurrent.TimeoutException
        Returns workflow result potentially waiting for workflow to complete. Behind the scene this call performs long poll on Temporal service waiting for workflow completion notification.
        Type Parameters:
        R - type of the workflow return value
        Parameters:
        timeout - maximum time to wait
        unit - unit of timeout
        resultClass - class of the workflow return value
        Returns:
        workflow return value
        Throws:
        java.util.concurrent.TimeoutException - if workflow is not completed after the timeout time.
      • getResultAsync

        <R> java.util.concurrent.CompletableFuture<R> getResultAsync​(long timeout,
                                                                     java.util.concurrent.TimeUnit unit,
                                                                     java.lang.Class<R> resultClass,
                                                                     java.lang.reflect.Type resultType)
      • getResultAsync

        <R> java.util.concurrent.CompletableFuture<R> getResultAsync​(long timeout,
                                                                     java.util.concurrent.TimeUnit unit,
                                                                     java.lang.Class<R> resultClass)
      • query

        <R> R query​(java.lang.String queryType,
                    java.lang.Class<R> resultClass,
                    java.lang.Object... args)
        Synchronously queries workflow by invoking its query handler. Usually a query handler is a method annotated with QueryMethod.
        Type Parameters:
        R - type of the query result
        Parameters:
        queryType - name of the query handler. Usually it is a method name.
        resultClass - class of the query result type
        args - optional query arguments
        Returns:
        query result
        Throws:
        WorkflowQueryException - if query failed for any reason
        See Also:
        WorkflowClientOptions.Builder.setQueryRejectCondition(QueryRejectCondition)
      • query

        <R> R query​(java.lang.String queryType,
                    java.lang.Class<R> resultClass,
                    java.lang.reflect.Type resultType,
                    java.lang.Object... args)
      • cancel

        void cancel()
        Request cancellation of a workflow execution.

        Cancellation cancels CancellationScope that wraps the main workflow method. Note that workflow can take long time to get canceled or even completely ignore the cancellation request.

      • terminate

        void terminate​(java.lang.String reason,
                       java.lang.Object... details)
        Terminates a workflow execution.

        Termination is a hard stop of a workflow execution which doesn't give workflow code any chance to perform cleanup.

        Parameters:
        reason - for the termination request
        details - additional details about the termination reason