Annotation Interface FlowableWorker
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 -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionOverride the container factory'sconcurrencysetting 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'spollingIntervalsetting for this worker.
-
Element Details
-
topic
String topicThe topic that should be handled by the worker
-
-
-
id
String idThe unique identifier of the container managing this endpoint.If none is specified, an auto-generated one is provided.
- Default:
- ""
-
lockDuration
String lockDurationThe duration for the lock when acquiring jobs. If not specified then the global configured default will be used.- Default:
- ""
-
numberOfRetries
String numberOfRetriesThe number of retries when acquiring jobs. If not specified then the global configured default will be used.- Default:
- ""
-
numberOfTasks
String numberOfTasksThe number of tasks that should be acquired . If not specified then the global configured default will be used.- Default:
- ""
-
pollingInterval
String pollingIntervalOverride the container factory'spollingIntervalsetting for this worker.- Default:
- ""
-
concurrency
String concurrencyOverride the container factory'sconcurrencysetting for this worker.- Default:
- ""
-