public interface ExternalTaskService
ExternalTask
instances. External tasks
represent work items that are processed externally and independently of the process
engine.Modifier and Type | Method and Description |
---|---|
void |
complete(String externalTaskId,
String workerId)
Completes an external task on behalf of a worker.
|
void |
complete(String externalTaskId,
String workerId,
Map<String,Object> variables)
Completes an external task on behalf of a worker and submits variables
to the process instance before continuing execution.
|
ExternalTaskQuery |
createExternalTaskQuery()
Queries for tasks that the currently authenticated user has at least one
of the following permissions for:
Permissions.READ on Resources.PROCESS_INSTANCE
Permissions.READ_INSTANCE on Resources.PROCESS_DEFINITION
|
ExternalTaskQueryBuilder |
fetchAndLock(int maxTasks,
String workerId)
Defines fetching of external tasks by using a fluent builder.
|
void |
handleFailure(String externalTaskId,
String workerId,
String errorMessage,
int retries,
long retryTimeout)
Signals that an external task could not be successfully executed.
|
void |
setRetries(String externalTaskId,
int retries)
Sets the retries for an external task.
|
void |
unlock(String externalTaskId)
Unlocks an external task instance.
|
ExternalTaskQueryBuilder fetchAndLock(int maxTasks, String workerId)
Defines fetching of external tasks by using a fluent builder. A worker id and a maximum number of tasks to fetch must be specified. The builder allows to specify multiple topics to fetch tasks for and individual lock durations. For every topic, variables can be fetched in addition.
Returned tasks are locked for the given worker until
now + lockDuration
expires.
Locked tasks cannot be fetched or completed by other workers. When the lock time has expired,
a task may be fetched and locked by other workers.
Returns at most maxTasks
tasks. The tasks are arbitrarily
distributed among the specified topics. Example: Fetching 10 tasks of topics
"a"/"b"/"c" may return 3/3/4 tasks, or 10/0/0 tasks, etc.
May return less than maxTasks
tasks, if there exist not enough
unlocked tasks matching the provided topics or if parallel fetching by other workers
results in locking failures.
Returns only tasks that the currently authenticated user has at least one permission out of all of the following groups for:
maxTasks
- the maximum number of tasks to returnworkerId
- the id of the worker to lock the tasks forvoid complete(String externalTaskId, String workerId)
Completes an external task on behalf of a worker. The given task must be assigned to the worker.
externalTaskId
- the id of the external to completeworkerId
- the id of the worker that completes the taskNotFoundException
- if no external task with the given id existsBadUserRequestException
- if the task is assigned to a different workerAuthorizationException
- thrown if the current user does not possess any of the following permissions:
void complete(String externalTaskId, String workerId, Map<String,Object> variables)
Completes an external task on behalf of a worker and submits variables to the process instance before continuing execution. The given task must be assigned to the worker.
externalTaskId
- the id of the external to completeworkerId
- the id of the worker that completes the taskvariables
- a map of variables to set on the execution (non-local)
the external task is assigned toNotFoundException
- if no external task with the given id existsBadUserRequestException
- if the task is assigned to a different workerAuthorizationException
- thrown if the current user does not possess any of the following permissions:
void handleFailure(String externalTaskId, String workerId, String errorMessage, int retries, long retryTimeout)
Signals that an external task could not be successfully executed. The task must be assigned to
the given worker. The number of retries left can be specified. In addition, a timeout can be
provided, such that the task cannot be fetched before now + retryTimeout
again.
If retries
is 0, an incident with the given error message is created. The incident gets resolved,
once the number of retries is increased again.
externalTaskId
- the id of the external task to report a failure forworkerId
- the id of the worker that reports the failureerrorMessage
- the error message related to this failure. This message can be retrieved via
ExternalTask.getErrorMessage()
and is used as the incident message in case retries
is null
.
May be null
.retries
- the number of retries left. External tasks with 0 retries cannot be fetched anymore unless
the number of retries is increased via API. Must be >= 0.retryTimeout
- the timeout before the task can be fetched again. Must be >= 0.NotFoundException
- if no external task with the given id existsBadUserRequestException
- if the task is assigned to a different workerAuthorizationException
- thrown if the current user does not possess any of the following permissions:
void unlock(String externalTaskId)
externalTaskId
- the id of the task to unlockNotFoundException
- if no external task with the given id existsAuthorizationException
- thrown if the current user does not possess any of the following permissions:
void setRetries(String externalTaskId, int retries)
null
message is created. If the old value is 0 and the new value is greater than 0, an existing incident
is resolved.externalTaskId
- the id of the task to set theretries
- NotFoundException
- if no external task with the given id existsAuthorizationException
- thrown if the current user does not possess any of the following permissions:
ExternalTaskQuery createExternalTaskQuery()
Queries for tasks that the currently authenticated user has at least one of the following permissions for:
ExternalTaskQuery
that can be used to dynamically
query for external tasks.Copyright © 2018. All rights reserved.