Class ExternalTaskEntity
- java.lang.Object
-
- org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity
-
- All Implemented Interfaces:
ExternalTask
,DbEntity
,HasDbReferences
,HasDbRevision
public class ExternalTaskEntity extends Object implements ExternalTask, DbEntity, HasDbRevision, HasDbReferences
- Author:
- Thorben Lindhauer, Askar Akhmerov
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ExternalTaskEntity()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areRetriesLeft()
void
bpmnError(String errorCode, String errorMessage, Map<String,Object> variables)
void
complete(Map<String,Object> variables, Map<String,Object> localVariables)
static ExternalTaskEntity
createAndInsert(ExecutionEntity execution, String topic, long priority)
protected void
createIncident()
protected IncidentContext
createIncidentContext()
void
delete()
protected void
deleteFromExecutionAndRuntimeTable(boolean incidentResolved)
protected void
ensureActive()
protected void
ensureErrorByteArrayInitialized()
protected void
ensureExecutionInitialized(boolean validateExistence)
protected void
ensureVariablesSet(ExecutionEntity execution, Map<String,Object> variables, Map<String,Object> localVariables)
protected boolean
errorEventDefinitionMatches(CamundaErrorEventDefinition camundaErrorEventDefinition, boolean continueOnException)
protected boolean
evaluateThrowBpmnError(ExecutionEntity execution, boolean continueOnException)
void
extendLock(long newLockExpirationTime)
void
failed(String errorMessage, String errorDetails, int retries, long retryDuration, Map<String,Object> variables, Map<String,Object> localVariables)
process failed state, make sure that binary entity is created for the errorMessage, shortError message does not exceed limit, handle properly retry counts and incidentsString
getActivityId()
String
getActivityInstanceId()
String
getBusinessKey()
Returns the business key of the process instance the external task belongs toprotected ByteArrayEntity
getErrorByteArray()
String
getErrorDetails()
Method implementation relies on the command context object, therefore should be invoked from the commands onlyString
getErrorDetailsByteArrayId()
String
getErrorMessage()
ExecutionEntity
getExecution()
ExecutionEntity
getExecution(boolean validateExistence)
String
getExecutionId()
Map<String,String>
getExtensionProperties()
Returns a map containing all custom extension properties of the external task.String
getId()
String
getLastFailureLogId()
Date
getLockExpirationTime()
Object
getPersistentState()
Returns a representation of the object, as would be stored in the database.long
getPriority()
Returns the priority of the external task.String
getProcessDefinitionId()
String
getProcessDefinitionKey()
String
getProcessDefinitionVersionTag()
String
getProcessInstanceId()
Map<String,Class>
getReferencedEntitiesIdAndClass()
Scope: IN-MEMORY referencesSet<String>
getReferencedEntityIds()
Scope: IN-MEMORY referencesInteger
getRetries()
int
getRevision()
int
getRevisionNext()
int
getSuspensionState()
String
getTenantId()
String
getTopicName()
String
getWorkerId()
void
insert()
boolean
isSuspended()
void
lock(String workerId, long lockDuration)
protected void
produceHistoricExternalTaskCreatedEvent()
protected void
produceHistoricExternalTaskDeletedEvent()
protected void
produceHistoricExternalTaskFailedEvent()
protected void
produceHistoricExternalTaskSuccessfulEvent()
protected void
removeIncidents(boolean incidentResolved)
void
setActivityId(String activityId)
void
setActivityInstanceId(String activityInstanceId)
void
setBusinessKey(String businessKey)
protected void
setErrorDetails(String exception)
void
setErrorMessage(String errorMessage)
void
setExecution(ExecutionEntity execution)
void
setExecutionId(String executionId)
void
setExtensionProperties(Map<String,String> extensionProperties)
void
setId(String id)
void
setLastFailureLogId(String lastFailureLogId)
void
setLockExpirationTime(Date lockExpirationTime)
void
setPriority(long priority)
void
setProcessDefinitionId(String processDefinitionId)
void
setProcessDefinitionKey(String processDefinitionKey)
void
setProcessDefinitionVersionTag(String processDefinitionVersionTag)
void
setProcessInstanceId(String processInstanceId)
void
setRetries(Integer retries)
void
setRetriesAndManageIncidents(int retries)
void
setRevision(int revision)
void
setSuspensionState(int suspensionState)
void
setTenantId(String tenantId)
void
setTopicName(String topic)
void
setWorkerId(String workerId)
String
toString()
void
unlock()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.camunda.bpm.engine.impl.db.HasDbReferences
getDependentEntities
-
-
-
-
Field Detail
-
LOG
protected static final EnginePersistenceLogger LOG
-
MAX_EXCEPTION_MESSAGE_LENGTH
public static final int MAX_EXCEPTION_MESSAGE_LENGTH
Note:String.length()
counts Unicode supplementary characters twice, so for a String consisting only of those, the limit is effectively MAX_EXCEPTION_MESSAGE_LENGTH / 2- See Also:
- Constant Field Values
-
id
protected String id
-
revision
protected int revision
-
topicName
protected String topicName
-
workerId
protected String workerId
-
lockExpirationTime
protected Date lockExpirationTime
-
retries
protected Integer retries
-
errorMessage
protected String errorMessage
-
errorDetailsByteArray
protected ByteArrayEntity errorDetailsByteArray
-
errorDetailsByteArrayId
protected String errorDetailsByteArrayId
-
suspensionState
protected int suspensionState
-
executionId
protected String executionId
-
processInstanceId
protected String processInstanceId
-
processDefinitionId
protected String processDefinitionId
-
processDefinitionKey
protected String processDefinitionKey
-
processDefinitionVersionTag
protected String processDefinitionVersionTag
-
activityId
protected String activityId
-
activityInstanceId
protected String activityInstanceId
-
tenantId
protected String tenantId
-
priority
protected long priority
-
execution
protected ExecutionEntity execution
-
businessKey
protected String businessKey
-
lastFailureLogId
protected String lastFailureLogId
-
-
Method Detail
-
getId
public String getId()
- Specified by:
getId
in interfaceDbEntity
- Specified by:
getId
in interfaceExternalTask
- Returns:
- the id of the task
-
getTopicName
public String getTopicName()
- Specified by:
getTopicName
in interfaceExternalTask
- Returns:
- the name of the topic the task belongs to
-
setTopicName
public void setTopicName(String topic)
-
getWorkerId
public String getWorkerId()
- Specified by:
getWorkerId
in interfaceExternalTask
- Returns:
- the id of the worker that has locked the task
-
setWorkerId
public void setWorkerId(String workerId)
-
getLockExpirationTime
public Date getLockExpirationTime()
- Specified by:
getLockExpirationTime
in interfaceExternalTask
- Returns:
- the absolute time at which the lock expires
-
setLockExpirationTime
public void setLockExpirationTime(Date lockExpirationTime)
-
getExecutionId
public String getExecutionId()
- Specified by:
getExecutionId
in interfaceExternalTask
- Returns:
- the id of the execution that the task is assigned to
-
setExecutionId
public void setExecutionId(String executionId)
-
getProcessDefinitionKey
public String getProcessDefinitionKey()
- Specified by:
getProcessDefinitionKey
in interfaceExternalTask
- Returns:
- the key of the process definition the tasks activity belongs to
-
setProcessDefinitionKey
public void setProcessDefinitionKey(String processDefinitionKey)
-
getProcessDefinitionVersionTag
public String getProcessDefinitionVersionTag()
- Specified by:
getProcessDefinitionVersionTag
in interfaceExternalTask
- Returns:
- the version tag of the process definition the tasks activity belongs to
-
setProcessDefinitionVersionTag
public void setProcessDefinitionVersionTag(String processDefinitionVersionTag)
-
getActivityId
public String getActivityId()
- Specified by:
getActivityId
in interfaceExternalTask
- Returns:
- the id of the activity for which the task is created
-
setActivityId
public void setActivityId(String activityId)
-
getActivityInstanceId
public String getActivityInstanceId()
- Specified by:
getActivityInstanceId
in interfaceExternalTask
- Returns:
- the id of the activity instance in which context the task exists
-
setActivityInstanceId
public void setActivityInstanceId(String activityInstanceId)
-
getRevision
public int getRevision()
- Specified by:
getRevision
in interfaceHasDbRevision
-
setRevision
public void setRevision(int revision)
- Specified by:
setRevision
in interfaceHasDbRevision
-
getRevisionNext
public int getRevisionNext()
- Specified by:
getRevisionNext
in interfaceHasDbRevision
-
getSuspensionState
public int getSuspensionState()
-
setSuspensionState
public void setSuspensionState(int suspensionState)
-
isSuspended
public boolean isSuspended()
- Specified by:
isSuspended
in interfaceExternalTask
- Returns:
- true if the external task is suspended; a suspended external task cannot be completed, thereby preventing process continuation
-
getProcessInstanceId
public String getProcessInstanceId()
- Specified by:
getProcessInstanceId
in interfaceExternalTask
- Returns:
- the id of the process instance the task exists in
-
setProcessInstanceId
public void setProcessInstanceId(String processInstanceId)
-
getProcessDefinitionId
public String getProcessDefinitionId()
- Specified by:
getProcessDefinitionId
in interfaceExternalTask
- Returns:
- the id of the process definition the tasks activity belongs to
-
setProcessDefinitionId
public void setProcessDefinitionId(String processDefinitionId)
-
getTenantId
public String getTenantId()
- Specified by:
getTenantId
in interfaceExternalTask
- Returns:
- the id of the tenant the task belongs to. Can be
null
if the task belongs to no single tenant.
-
setTenantId
public void setTenantId(String tenantId)
-
getRetries
public Integer getRetries()
- Specified by:
getRetries
in interfaceExternalTask
- Returns:
- the number of retries left. The number of retries is provided by
a task client, therefore the initial value is
null
.
-
setRetries
public void setRetries(Integer retries)
-
getErrorMessage
public String getErrorMessage()
- Specified by:
getErrorMessage
in interfaceExternalTask
- Returns:
- short error message submitted with the latest reported failure executing this task;
null
if no failure was reported previously or if no error message was submitted - See Also:
To get the full error details, use
-
areRetriesLeft
public boolean areRetriesLeft()
-
getPriority
public long getPriority()
Description copied from interface:ExternalTask
Returns the priority of the external task.- Specified by:
getPriority
in interfaceExternalTask
- Returns:
- the priority of the external task
-
setPriority
public void setPriority(long priority)
-
getBusinessKey
public String getBusinessKey()
Description copied from interface:ExternalTask
Returns the business key of the process instance the external task belongs to- Specified by:
getBusinessKey
in interfaceExternalTask
- Returns:
- the business key
-
setBusinessKey
public void setBusinessKey(String businessKey)
-
getExtensionProperties
public Map<String,String> getExtensionProperties()
Description copied from interface:ExternalTask
Returns a map containing all custom extension properties of the external task.- Specified by:
getExtensionProperties
in interfaceExternalTask
- Returns:
- the properties, never
null
-
getPersistentState
public Object getPersistentState()
Description copied from interface:DbEntity
Returns a representation of the object, as would be stored in the database. Used when deciding if updates have occurred to the object or not since it was last loaded.- Specified by:
getPersistentState
in interfaceDbEntity
-
insert
public void insert()
-
getErrorDetails
public String getErrorDetails()
Method implementation relies on the command context object, therefore should be invoked from the commands only- Returns:
- error details persisted in byte array table
-
setErrorMessage
public void setErrorMessage(String errorMessage)
-
setErrorDetails
protected void setErrorDetails(String exception)
-
getErrorDetailsByteArrayId
public String getErrorDetailsByteArrayId()
-
getErrorByteArray
protected ByteArrayEntity getErrorByteArray()
-
ensureErrorByteArrayInitialized
protected void ensureErrorByteArrayInitialized()
-
delete
public void delete()
-
deleteFromExecutionAndRuntimeTable
protected void deleteFromExecutionAndRuntimeTable(boolean incidentResolved)
-
removeIncidents
protected void removeIncidents(boolean incidentResolved)
-
failed
public void failed(String errorMessage, String errorDetails, int retries, long retryDuration, Map<String,Object> variables, Map<String,Object> localVariables)
process failed state, make sure that binary entity is created for the errorMessage, shortError message does not exceed limit, handle properly retry counts and incidents- Parameters:
errorMessage
- - short error message texterrorDetails
- - full error detailsretries
- - updated value of retries leftretryDuration
- - used for lockExpirationTime calculation
-
bpmnError
public void bpmnError(String errorCode, String errorMessage, Map<String,Object> variables)
-
setRetriesAndManageIncidents
public void setRetriesAndManageIncidents(int retries)
-
createIncident
protected void createIncident()
-
createIncidentContext
protected IncidentContext createIncidentContext()
-
lock
public void lock(String workerId, long lockDuration)
-
getExecution
public ExecutionEntity getExecution()
-
getExecution
public ExecutionEntity getExecution(boolean validateExistence)
-
setExecution
public void setExecution(ExecutionEntity execution)
-
ensureExecutionInitialized
protected void ensureExecutionInitialized(boolean validateExistence)
-
ensureActive
protected void ensureActive()
-
ensureVariablesSet
protected void ensureVariablesSet(ExecutionEntity execution, Map<String,Object> variables, Map<String,Object> localVariables)
-
evaluateThrowBpmnError
protected boolean evaluateThrowBpmnError(ExecutionEntity execution, boolean continueOnException)
-
errorEventDefinitionMatches
protected boolean errorEventDefinitionMatches(CamundaErrorEventDefinition camundaErrorEventDefinition, boolean continueOnException)
-
unlock
public void unlock()
-
createAndInsert
public static ExternalTaskEntity createAndInsert(ExecutionEntity execution, String topic, long priority)
-
produceHistoricExternalTaskCreatedEvent
protected void produceHistoricExternalTaskCreatedEvent()
-
produceHistoricExternalTaskFailedEvent
protected void produceHistoricExternalTaskFailedEvent()
-
produceHistoricExternalTaskSuccessfulEvent
protected void produceHistoricExternalTaskSuccessfulEvent()
-
produceHistoricExternalTaskDeletedEvent
protected void produceHistoricExternalTaskDeletedEvent()
-
extendLock
public void extendLock(long newLockExpirationTime)
-
getReferencedEntityIds
public Set<String> getReferencedEntityIds()
Description copied from interface:HasDbReferences
Scope: IN-MEMORY references
- Specified by:
getReferencedEntityIds
in interfaceHasDbReferences
- Returns:
- the ids of the entities that this entity references. Should only return ids for entities of the same type
-
getReferencedEntitiesIdAndClass
public Map<String,Class> getReferencedEntitiesIdAndClass()
Description copied from interface:HasDbReferences
Scope: IN-MEMORY references
- Specified by:
getReferencedEntitiesIdAndClass
in interfaceHasDbReferences
- Returns:
- a map of the ids and the entities' classes that this entity references. It's used when trying to determine if there was an Optimistic Locking occurrence on an INSERT or UPDATE of an object of this type.
-
getLastFailureLogId
public String getLastFailureLogId()
-
setLastFailureLogId
public void setLastFailureLogId(String lastFailureLogId)
-
-