Search in sources :

Example 1 with LockedExternalTaskImpl

use of org.camunda.bpm.engine.impl.externaltask.LockedExternalTaskImpl in project camunda-bpm-platform by camunda.

the class FetchExternalTasksCmd method execute.

@Override
public List<LockedExternalTask> execute(CommandContext commandContext) {
    validateInput();
    for (TopicFetchInstruction instruction : fetchInstructions.values()) {
        instruction.ensureVariablesInitialized();
    }
    List<ExternalTaskEntity> externalTasks = commandContext.getExternalTaskManager().selectExternalTasksForTopics(fetchInstructions.values(), filterByBusinessKey, maxResults, usePriority);
    final List<LockedExternalTask> result = new ArrayList<LockedExternalTask>();
    for (ExternalTaskEntity entity : externalTasks) {
        TopicFetchInstruction fetchInstruction = fetchInstructions.get(entity.getTopicName());
        entity.lock(workerId, fetchInstruction.getLockDuration());
        LockedExternalTaskImpl resultTask = LockedExternalTaskImpl.fromEntity(entity, fetchInstruction.getVariablesToFetch(), fetchInstruction.isDeserializeVariables());
        result.add(resultTask);
    }
    filterOnOptimisticLockingFailure(commandContext, result);
    return result;
}
Also used : ExternalTaskEntity(org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity) LockedExternalTaskImpl(org.camunda.bpm.engine.impl.externaltask.LockedExternalTaskImpl) TopicFetchInstruction(org.camunda.bpm.engine.impl.externaltask.TopicFetchInstruction) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Aggregations

LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)1 LockedExternalTaskImpl (org.camunda.bpm.engine.impl.externaltask.LockedExternalTaskImpl)1 TopicFetchInstruction (org.camunda.bpm.engine.impl.externaltask.TopicFetchInstruction)1 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)1