Class ExternalTaskEntity
- java.lang.Object
-
- org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity
-
- All Implemented Interfaces:
ExternalTask
,DbEntity
,HasDbReferences
,HasDbRevision
public class ExternalTaskEntity extends java.lang.Object implements ExternalTask, DbEntity, HasDbRevision, HasDbReferences
- Author:
- Thorben Lindhauer, Askar Akhmerov
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
activityId
protected java.lang.String
activityInstanceId
protected java.lang.String
businessKey
protected ByteArrayEntity
errorDetailsByteArray
protected java.lang.String
errorDetailsByteArrayId
protected java.lang.String
errorMessage
protected ExecutionEntity
execution
protected java.lang.String
executionId
protected java.util.Map<java.lang.String,java.lang.String>
extensionProperties
protected java.lang.String
id
protected java.lang.String
lastFailureLogId
protected java.util.Date
lockExpirationTime
protected static EnginePersistenceLogger
LOG
static 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 / 2protected long
priority
protected java.lang.String
processDefinitionId
protected java.lang.String
processDefinitionKey
protected java.lang.String
processDefinitionVersionTag
protected java.lang.String
processInstanceId
protected java.lang.Integer
retries
protected int
revision
protected int
suspensionState
protected java.lang.String
tenantId
protected java.lang.String
topicName
protected java.lang.String
workerId
-
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(java.lang.String errorCode, java.lang.String errorMessage, java.util.Map<java.lang.String,java.lang.Object> variables)
void
complete(java.util.Map<java.lang.String,java.lang.Object> variables, java.util.Map<java.lang.String,java.lang.Object> localVariables)
static ExternalTaskEntity
createAndInsert(ExecutionEntity execution, java.lang.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, java.util.Map<java.lang.String,java.lang.Object> variables, java.util.Map<java.lang.String,java.lang.Object> localVariables)
protected boolean
errorEventDefinitionMatches(CamundaErrorEventDefinition camundaErrorEventDefinition, boolean continueOnException)
protected boolean
evaluateThrowBpmnError(ExecutionEntity execution, boolean continueOnException)
void
extendLock(long newLockExpirationTime)
void
failed(java.lang.String errorMessage, java.lang.String errorDetails, int retries, long retryDuration, java.util.Map<java.lang.String,java.lang.Object> variables, java.util.Map<java.lang.String,java.lang.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 incidentsjava.lang.String
getActivityId()
java.lang.String
getActivityInstanceId()
java.lang.String
getBusinessKey()
Returns the business key of the process instance the external task belongs toprotected ByteArrayEntity
getErrorByteArray()
java.lang.String
getErrorDetails()
Method implementation relies on the command context object, therefore should be invoked from the commands onlyjava.lang.String
getErrorDetailsByteArrayId()
java.lang.String
getErrorMessage()
ExecutionEntity
getExecution()
ExecutionEntity
getExecution(boolean validateExistence)
java.lang.String
getExecutionId()
java.util.Map<java.lang.String,java.lang.String>
getExtensionProperties()
Returns a map containing all custom extension properties of the external task.java.lang.String
getId()
java.lang.String
getLastFailureLogId()
java.util.Date
getLockExpirationTime()
java.lang.Object
getPersistentState()
Returns a representation of the object, as would be stored in the database.long
getPriority()
Returns the priority of the external task.java.lang.String
getProcessDefinitionId()
java.lang.String
getProcessDefinitionKey()
java.lang.String
getProcessDefinitionVersionTag()
java.lang.String
getProcessInstanceId()
java.util.Map<java.lang.String,java.lang.Class>
getReferencedEntitiesIdAndClass()
Scope: IN-MEMORY referencesjava.util.Set<java.lang.String>
getReferencedEntityIds()
Scope: IN-MEMORY referencesjava.lang.Integer
getRetries()
int
getRevision()
int
getRevisionNext()
int
getSuspensionState()
java.lang.String
getTenantId()
java.lang.String
getTopicName()
java.lang.String
getWorkerId()
void
insert()
boolean
isSuspended()
void
lock(java.lang.String workerId, long lockDuration)
protected void
produceHistoricExternalTaskCreatedEvent()
protected void
produceHistoricExternalTaskDeletedEvent()
protected void
produceHistoricExternalTaskFailedEvent()
protected void
produceHistoricExternalTaskSuccessfulEvent()
protected void
removeIncidents(boolean incidentResolved)
void
setActivityId(java.lang.String activityId)
void
setActivityInstanceId(java.lang.String activityInstanceId)
void
setBusinessKey(java.lang.String businessKey)
protected void
setErrorDetails(java.lang.String exception)
void
setErrorMessage(java.lang.String errorMessage)
void
setExecution(ExecutionEntity execution)
void
setExecutionId(java.lang.String executionId)
void
setExtensionProperties(java.util.Map<java.lang.String,java.lang.String> extensionProperties)
void
setId(java.lang.String id)
void
setLastFailureLogId(java.lang.String lastFailureLogId)
void
setLockExpirationTime(java.util.Date lockExpirationTime)
void
setPriority(long priority)
void
setProcessDefinitionId(java.lang.String processDefinitionId)
void
setProcessDefinitionKey(java.lang.String processDefinitionKey)
void
setProcessDefinitionVersionTag(java.lang.String processDefinitionVersionTag)
void
setProcessInstanceId(java.lang.String processInstanceId)
void
setRetries(java.lang.Integer retries)
void
setRetriesAndManageIncidents(int retries)
void
setRevision(int revision)
void
setSuspensionState(int suspensionState)
void
setTenantId(java.lang.String tenantId)
void
setTopicName(java.lang.String topic)
void
setWorkerId(java.lang.String workerId)
java.lang.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 java.lang.String id
-
revision
protected int revision
-
topicName
protected java.lang.String topicName
-
workerId
protected java.lang.String workerId
-
lockExpirationTime
protected java.util.Date lockExpirationTime
-
retries
protected java.lang.Integer retries
-
errorMessage
protected java.lang.String errorMessage
-
errorDetailsByteArray
protected ByteArrayEntity errorDetailsByteArray
-
errorDetailsByteArrayId
protected java.lang.String errorDetailsByteArrayId
-
suspensionState
protected int suspensionState
-
executionId
protected java.lang.String executionId
-
processInstanceId
protected java.lang.String processInstanceId
-
processDefinitionId
protected java.lang.String processDefinitionId
-
processDefinitionKey
protected java.lang.String processDefinitionKey
-
processDefinitionVersionTag
protected java.lang.String processDefinitionVersionTag
-
activityId
protected java.lang.String activityId
-
activityInstanceId
protected java.lang.String activityInstanceId
-
tenantId
protected java.lang.String tenantId
-
priority
protected long priority
-
extensionProperties
protected java.util.Map<java.lang.String,java.lang.String> extensionProperties
-
execution
protected ExecutionEntity execution
-
businessKey
protected java.lang.String businessKey
-
lastFailureLogId
protected java.lang.String lastFailureLogId
-
-
Method Detail
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceDbEntity
- Specified by:
getId
in interfaceExternalTask
- Returns:
- the id of the task
-
getTopicName
public java.lang.String getTopicName()
- Specified by:
getTopicName
in interfaceExternalTask
- Returns:
- the name of the topic the task belongs to
-
setTopicName
public void setTopicName(java.lang.String topic)
-
getWorkerId
public java.lang.String getWorkerId()
- Specified by:
getWorkerId
in interfaceExternalTask
- Returns:
- the id of the worker that has locked the task
-
setWorkerId
public void setWorkerId(java.lang.String workerId)
-
getLockExpirationTime
public java.util.Date getLockExpirationTime()
- Specified by:
getLockExpirationTime
in interfaceExternalTask
- Returns:
- the absolute time at which the lock expires
-
setLockExpirationTime
public void setLockExpirationTime(java.util.Date lockExpirationTime)
-
getExecutionId
public java.lang.String getExecutionId()
- Specified by:
getExecutionId
in interfaceExternalTask
- Returns:
- the id of the execution that the task is assigned to
-
setExecutionId
public void setExecutionId(java.lang.String executionId)
-
getProcessDefinitionKey
public java.lang.String getProcessDefinitionKey()
- Specified by:
getProcessDefinitionKey
in interfaceExternalTask
- Returns:
- the key of the process definition the tasks activity belongs to
-
setProcessDefinitionKey
public void setProcessDefinitionKey(java.lang.String processDefinitionKey)
-
getProcessDefinitionVersionTag
public java.lang.String getProcessDefinitionVersionTag()
- Specified by:
getProcessDefinitionVersionTag
in interfaceExternalTask
- Returns:
- the version tag of the process definition the tasks activity belongs to
-
setProcessDefinitionVersionTag
public void setProcessDefinitionVersionTag(java.lang.String processDefinitionVersionTag)
-
getActivityId
public java.lang.String getActivityId()
- Specified by:
getActivityId
in interfaceExternalTask
- Returns:
- the id of the activity for which the task is created
-
setActivityId
public void setActivityId(java.lang.String activityId)
-
getActivityInstanceId
public java.lang.String getActivityInstanceId()
- Specified by:
getActivityInstanceId
in interfaceExternalTask
- Returns:
- the id of the activity instance in which context the task exists
-
setActivityInstanceId
public void setActivityInstanceId(java.lang.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 java.lang.String getProcessInstanceId()
- Specified by:
getProcessInstanceId
in interfaceExternalTask
- Returns:
- the id of the process instance the task exists in
-
setProcessInstanceId
public void setProcessInstanceId(java.lang.String processInstanceId)
-
getProcessDefinitionId
public java.lang.String getProcessDefinitionId()
- Specified by:
getProcessDefinitionId
in interfaceExternalTask
- Returns:
- the id of the process definition the tasks activity belongs to
-
setProcessDefinitionId
public void setProcessDefinitionId(java.lang.String processDefinitionId)
-
getTenantId
public java.lang.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(java.lang.String tenantId)
-
getRetries
public java.lang.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(java.lang.Integer retries)
-
getErrorMessage
public java.lang.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 java.lang.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(java.lang.String businessKey)
-
getExtensionProperties
public java.util.Map<java.lang.String,java.lang.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
-
setExtensionProperties
public void setExtensionProperties(java.util.Map<java.lang.String,java.lang.String> extensionProperties)
-
getPersistentState
public java.lang.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 java.lang.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(java.lang.String errorMessage)
-
setErrorDetails
protected void setErrorDetails(java.lang.String exception)
-
getErrorDetailsByteArrayId
public java.lang.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)
-
complete
public void complete(java.util.Map<java.lang.String,java.lang.Object> variables, java.util.Map<java.lang.String,java.lang.Object> localVariables)
-
failed
public void failed(java.lang.String errorMessage, java.lang.String errorDetails, int retries, long retryDuration, java.util.Map<java.lang.String,java.lang.Object> variables, java.util.Map<java.lang.String,java.lang.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(java.lang.String errorCode, java.lang.String errorMessage, java.util.Map<java.lang.String,java.lang.Object> variables)
-
setRetriesAndManageIncidents
public void setRetriesAndManageIncidents(int retries)
-
createIncident
protected void createIncident()
-
createIncidentContext
protected IncidentContext createIncidentContext()
-
lock
public void lock(java.lang.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, java.util.Map<java.lang.String,java.lang.Object> variables, java.util.Map<java.lang.String,java.lang.Object> localVariables)
-
evaluateThrowBpmnError
protected boolean evaluateThrowBpmnError(ExecutionEntity execution, boolean continueOnException)
-
errorEventDefinitionMatches
protected boolean errorEventDefinitionMatches(CamundaErrorEventDefinition camundaErrorEventDefinition, boolean continueOnException)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
unlock
public void unlock()
-
createAndInsert
public static ExternalTaskEntity createAndInsert(ExecutionEntity execution, java.lang.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 java.util.Set<java.lang.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 java.util.Map<java.lang.String,java.lang.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 java.lang.String getLastFailureLogId()
-
setLastFailureLogId
public void setLastFailureLogId(java.lang.String lastFailureLogId)
-
-