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 booleanareRetriesLeft()voidbpmnError(String errorCode, String errorMessage, Map<String,Object> variables)voidcomplete(Map<String,Object> variables, Map<String,Object> localVariables)static ExternalTaskEntitycreateAndInsert(ExecutionEntity execution, String topic, long priority)protected voidcreateIncident()protected IncidentContextcreateIncidentContext()voiddelete()protected voiddeleteFromExecutionAndRuntimeTable(boolean incidentResolved)protected voidensureActive()protected voidensureErrorByteArrayInitialized()protected voidensureExecutionInitialized(boolean validateExistence)protected voidensureVariablesSet(ExecutionEntity execution, Map<String,Object> variables, Map<String,Object> localVariables)protected booleanerrorEventDefinitionMatches(CamundaErrorEventDefinition camundaErrorEventDefinition, boolean continueOnException)protected booleanevaluateThrowBpmnError(ExecutionEntity execution, boolean continueOnException)voidextendLock(long newLockExpirationTime)voidfailed(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 incidentsStringgetActivityId()StringgetActivityInstanceId()StringgetBusinessKey()Returns the business key of the process instance the external task belongs toprotected ByteArrayEntitygetErrorByteArray()StringgetErrorDetails()Method implementation relies on the command context object, therefore should be invoked from the commands onlyStringgetErrorDetailsByteArrayId()StringgetErrorMessage()ExecutionEntitygetExecution()ExecutionEntitygetExecution(boolean validateExistence)StringgetExecutionId()Map<String,String>getExtensionProperties()Returns a map containing all custom extension properties of the external task.StringgetId()StringgetLastFailureLogId()DategetLockExpirationTime()ObjectgetPersistentState()Returns a representation of the object, as would be stored in the database.longgetPriority()Returns the priority of the external task.StringgetProcessDefinitionId()StringgetProcessDefinitionKey()StringgetProcessDefinitionVersionTag()StringgetProcessInstanceId()Map<String,Class>getReferencedEntitiesIdAndClass()Scope: IN-MEMORY referencesSet<String>getReferencedEntityIds()Scope: IN-MEMORY referencesIntegergetRetries()intgetRevision()intgetRevisionNext()intgetSuspensionState()StringgetTenantId()StringgetTopicName()StringgetWorkerId()voidinsert()booleanisSuspended()voidlock(String workerId, long lockDuration)protected voidproduceHistoricExternalTaskCreatedEvent()protected voidproduceHistoricExternalTaskDeletedEvent()protected voidproduceHistoricExternalTaskFailedEvent()protected voidproduceHistoricExternalTaskSuccessfulEvent()protected voidremoveIncidents(boolean incidentResolved)voidsetActivityId(String activityId)voidsetActivityInstanceId(String activityInstanceId)voidsetBusinessKey(String businessKey)protected voidsetErrorDetails(String exception)voidsetErrorMessage(String errorMessage)voidsetExecution(ExecutionEntity execution)voidsetExecutionId(String executionId)voidsetExtensionProperties(Map<String,String> extensionProperties)voidsetId(String id)voidsetLastFailureLogId(String lastFailureLogId)voidsetLockExpirationTime(Date lockExpirationTime)voidsetPriority(long priority)voidsetProcessDefinitionId(String processDefinitionId)voidsetProcessDefinitionKey(String processDefinitionKey)voidsetProcessDefinitionVersionTag(String processDefinitionVersionTag)voidsetProcessInstanceId(String processInstanceId)voidsetRetries(Integer retries)voidsetRetriesAndManageIncidents(int retries)voidsetRevision(int revision)voidsetSuspensionState(int suspensionState)voidsetTenantId(String tenantId)voidsetTopicName(String topic)voidsetWorkerId(String workerId)StringtoString()voidunlock()-
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:
getIdin interfaceDbEntity- Specified by:
getIdin interfaceExternalTask- Returns:
- the id of the task
-
getTopicName
public String getTopicName()
- Specified by:
getTopicNamein interfaceExternalTask- Returns:
- the name of the topic the task belongs to
-
setTopicName
public void setTopicName(String topic)
-
getWorkerId
public String getWorkerId()
- Specified by:
getWorkerIdin interfaceExternalTask- Returns:
- the id of the worker that has locked the task
-
setWorkerId
public void setWorkerId(String workerId)
-
getLockExpirationTime
public Date getLockExpirationTime()
- Specified by:
getLockExpirationTimein interfaceExternalTask- Returns:
- the absolute time at which the lock expires
-
setLockExpirationTime
public void setLockExpirationTime(Date lockExpirationTime)
-
getExecutionId
public String getExecutionId()
- Specified by:
getExecutionIdin 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:
getProcessDefinitionKeyin 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:
getProcessDefinitionVersionTagin 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:
getActivityIdin 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:
getActivityInstanceIdin 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:
getRevisionin interfaceHasDbRevision
-
setRevision
public void setRevision(int revision)
- Specified by:
setRevisionin interfaceHasDbRevision
-
getRevisionNext
public int getRevisionNext()
- Specified by:
getRevisionNextin interfaceHasDbRevision
-
getSuspensionState
public int getSuspensionState()
-
setSuspensionState
public void setSuspensionState(int suspensionState)
-
isSuspended
public boolean isSuspended()
- Specified by:
isSuspendedin 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:
getProcessInstanceIdin interfaceExternalTask- Returns:
- the id of the process instance the task exists in
-
setProcessInstanceId
public void setProcessInstanceId(String processInstanceId)
-
getProcessDefinitionId
public String getProcessDefinitionId()
- Specified by:
getProcessDefinitionIdin 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:
getTenantIdin interfaceExternalTask- Returns:
- the id of the tenant the task belongs to. Can be
nullif the task belongs to no single tenant.
-
setTenantId
public void setTenantId(String tenantId)
-
getRetries
public Integer getRetries()
- Specified by:
getRetriesin 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:
getErrorMessagein interfaceExternalTask- Returns:
- short error message submitted with the latest reported failure executing this task;
nullif 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:ExternalTaskReturns the priority of the external task.- Specified by:
getPriorityin interfaceExternalTask- Returns:
- the priority of the external task
-
setPriority
public void setPriority(long priority)
-
getBusinessKey
public String getBusinessKey()
Description copied from interface:ExternalTaskReturns the business key of the process instance the external task belongs to- Specified by:
getBusinessKeyin interfaceExternalTask- Returns:
- the business key
-
setBusinessKey
public void setBusinessKey(String businessKey)
-
getExtensionProperties
public Map<String,String> getExtensionProperties()
Description copied from interface:ExternalTaskReturns a map containing all custom extension properties of the external task.- Specified by:
getExtensionPropertiesin interfaceExternalTask- Returns:
- the properties, never
null
-
getPersistentState
public Object getPersistentState()
Description copied from interface:DbEntityReturns 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:
getPersistentStatein 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:HasDbReferencesScope: IN-MEMORY references
- Specified by:
getReferencedEntityIdsin 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:HasDbReferencesScope: IN-MEMORY references
- Specified by:
getReferencedEntitiesIdAndClassin 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)
-
-