Interface Workflow

All Superinterfaces:
Serializable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Workflow extends Serializable
Functional interface for Kafka workflows definitions.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    A short-cut to WorkflowContext.current.get().await(v)
    static String
    A short-cut to WorkflowContext.current.get().await(newVar(name))
    static void
    forward(String child, String value)
    Forwards a record into registered Processor sink, using the current thread id as the record's key
    static void
    forward(String child, String key, String value)
    Forwards a record into registered Processor sink
    static org.apache.kafka.streams.processor.api.ProcessorContext<String,String>
    Getting current org.apache.kafka.streams.processor.api.ProcessorContext from Kafka Streams API
    static String
    Gets current thread
    static Var
    Generates a new variable on which workflows can suspend with an unique identifier
    static Var
    Generates a new variable on which workflows can suspend with a specific local identifier
    void
    run(String parameter)
    The method to implement (or a lambda) for the workflow definition.
  • Method Details

    • run

      void run(String parameter) throws io.github.javactrl.rt.CThrowable
      The method to implement (or a lambda) for the workflow definition. Workflow functions are just simple Java functions, but they can be suspended for a long time (days, months etc), and resumed after this. The function is converted into a plain Apache Kafka Streams Processor.
      Parameters:
      parameter - parameter received by the workflow's starting message
      Throws:
      io.github.javactrl.rt.CThrowable - if suspends or there is an error
    • getProcessorContext

      static org.apache.kafka.streams.processor.api.ProcessorContext<String,String> getProcessorContext()
      Getting current org.apache.kafka.streams.processor.api.ProcessorContext from Kafka Streams API
      Returns:
      the current processor context
    • getThreadId

      static String getThreadId()
      Gets current thread
      Returns:
      thread id string
    • newVar

      static Var newVar()
      Generates a new variable on which workflows can suspend with an unique identifier
      Returns:
      frash Var object
    • newVar

      static Var newVar(String id)
      Generates a new variable on which workflows can suspend with a specific local identifier
      Parameters:
      id - the name of the variable
      Returns:
      fresh Var object
    • await

      static String await(Var v) throws io.github.javactrl.rt.CThrowable
      A short-cut to WorkflowContext.current.get().await(v)
      Parameters:
      v - Var object to suspend on
      Returns:
      result value on resumption
      Throws:
      io.github.javactrl.rt.CThrowable - if suspended (always when this is called) or failed after resumption
      See Also:
      • WorkflowContext.await(Var)
    • await

      static String await(String id) throws io.github.javactrl.rt.CThrowable
      A short-cut to WorkflowContext.current.get().await(newVar(name))
      Parameters:
      id - local identifier of a new Var object
      Returns:
      result value on resumption
      Throws:
      io.github.javactrl.rt.CThrowable - if suspended (always when this is called) or failed after resumption
      See Also:
      • WorkflowContext.await(Var)
    • forward

      static void forward(String child, String key, String value)
      Forwards a record into registered Processor sink
      Parameters:
      child - name of the sink
      key - record's name
      value - record's value
    • forward

      static void forward(String child, String value)
      Forwards a record into registered Processor sink, using the current thread id as the record's key
      Parameters:
      child - name of the sink
      value - record's value