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 Details

    • 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:
    • 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
    • extensionProperties

      protected Map<String,String> extensionProperties
    • execution

      protected ExecutionEntity execution
    • businessKey

      protected String businessKey
    • lastFailureLogId

      protected String lastFailureLogId
  • Constructor Details

    • ExternalTaskEntity

      public ExternalTaskEntity()
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface DbEntity
      Specified by:
      getId in interface ExternalTask
      Returns:
      the id of the task
    • setId

      public void setId(String id)
      Specified by:
      setId in interface DbEntity
    • getTopicName

      public String getTopicName()
      Specified by:
      getTopicName in interface ExternalTask
      Returns:
      the name of the topic the task belongs to
    • setTopicName

      public void setTopicName(String topic)
    • getWorkerId

      public String getWorkerId()
      Specified by:
      getWorkerId in interface ExternalTask
      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 interface ExternalTask
      Returns:
      the absolute time at which the lock expires
    • setLockExpirationTime

      public void setLockExpirationTime(Date lockExpirationTime)
    • getExecutionId

      public String getExecutionId()
      Specified by:
      getExecutionId in interface ExternalTask
      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 interface ExternalTask
      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 interface ExternalTask
      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 interface ExternalTask
      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 interface ExternalTask
      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 interface HasDbRevision
    • setRevision

      public void setRevision(int revision)
      Specified by:
      setRevision in interface HasDbRevision
    • getRevisionNext

      public int getRevisionNext()
      Specified by:
      getRevisionNext in interface HasDbRevision
    • getSuspensionState

      public int getSuspensionState()
    • setSuspensionState

      public void setSuspensionState(int suspensionState)
    • isSuspended

      public boolean isSuspended()
      Specified by:
      isSuspended in interface ExternalTask
      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 interface ExternalTask
      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 interface ExternalTask
      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 interface ExternalTask
      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 interface ExternalTask
      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 interface ExternalTask
      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:
    • areRetriesLeft

      public boolean areRetriesLeft()
    • getPriority

      public long getPriority()
      Description copied from interface: ExternalTask
      Returns the priority of the external task.
      Specified by:
      getPriority in interface ExternalTask
      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 interface ExternalTask
      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 interface ExternalTask
      Returns:
      the properties, never null
    • setExtensionProperties

      public void setExtensionProperties(Map<String,String> extensionProperties)
    • 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 interface DbEntity
    • 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)
    • complete

      public void complete(Map<String,Object> variables, Map<String,Object> localVariables)
    • 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 text
      errorDetails - - full error details
      retries - - updated value of retries left
      retryDuration - - 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)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 interface HasDbReferences
      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 interface HasDbReferences
      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)