Search in sources :

Example 1 with TopicFetchInstruction

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

the class FetchExternalTasksCmd method validateInput.

protected void validateInput() {
    EnsureUtil.ensureNotNull("workerId", workerId);
    EnsureUtil.ensureGreaterThanOrEqual("maxResults", maxResults, 0);
    for (TopicFetchInstruction instruction : fetchInstructions.values()) {
        EnsureUtil.ensureNotNull("topicName", instruction.getTopicName());
        EnsureUtil.ensurePositive("lockTime", instruction.getLockDuration());
    }
}
Also used : TopicFetchInstruction(org.camunda.bpm.engine.impl.externaltask.TopicFetchInstruction)

Example 2 with TopicFetchInstruction

use of org.camunda.bpm.engine.impl.externaltask.TopicFetchInstruction 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

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