Annotation Interface FlowableWorker


@Target({METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) @Documented @Repeatable(FlowableWorkers.class) @MessageMapping public @interface FlowableWorker
Annotation that marks a method to be the target of an External Worker Job for the specific topic().

Processing of FlowableWorker annotations is performed by registering a FlowableWorkerAnnotationBeanPostProcessor. This can be done manually or through the @EnableFlowableWorker annotation.

Annotation Flowable Worker methods are allowed to have flexible signatures. Similar to what @MessageMapping provides.

Annotated methods may have a non-void return type. More specifically they may return WorkerResult. This allows to pass additional variables when completing the job by using WorkerResult.Success or additional information when failing the job using WorkerResult.Failure. An instance of the specific result can be created by using WorkerResultBuilder as a parameter of the method. e.g.


 package com.example.demo

 @Component
 public class ExampleWorker {

     @FlowableWorker(topic = "myTopic")
     public WorkerResult processJob(AcquiredExternalWorkerJob job, WorkerResultBuilder resultBuilder) {
         System.out.println("Executed job: " + job.getId());
         Object errorMessage = job.getVariables().get("errorMessage");
         if (errorMessage != null) {
             return resultBuilder.failure()
                     .message(errorMessage.toString())
                     .details("Error message details");
         }

         return resultBuilder.success()
                 .variable("message", "Job has been executed");
     }
 }
Author:
Filip Hrisafov
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The topic that should be handled by the worker
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Override the container factory's concurrency setting for this worker.
    The unique identifier of the container managing this endpoint.
    The duration for the lock when acquiring jobs.
    The number of retries when acquiring jobs.
    The number of tasks that should be acquired .
    Override the container factory's pollingInterval setting for this worker.
  • Element Details

    • topic

      String topic
      The topic that should be handled by the worker
    • id

      String id
      The unique identifier of the container managing this endpoint.

      If none is specified, an auto-generated one is provided.

      See Also:
      Default:
      ""
    • lockDuration

      String lockDuration
      The duration for the lock when acquiring jobs. If not specified then the global configured default will be used.
      Default:
      ""
    • numberOfRetries

      String numberOfRetries
      The number of retries when acquiring jobs. If not specified then the global configured default will be used.
      Default:
      ""
    • numberOfTasks

      String numberOfTasks
      The number of tasks that should be acquired . If not specified then the global configured default will be used.
      Default:
      ""
    • pollingInterval

      String pollingInterval
      Override the container factory's pollingInterval setting for this worker.
      Default:
      ""
    • concurrency

      String concurrency
      Override the container factory's concurrency setting for this worker.
      Default:
      ""