All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.pythagoras.common.aggregationqueue.AggregationQueueServiceImpl Maven / Gradle / Ivy

The newest version!
package io.pythagoras.common.aggregationqueue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Service
public class AggregationQueueServiceImpl implements AggregationQueueService {


    private QueueManager queueManager;

    private AggregationQueueProperties aggregationQueueProperties;

    @Autowired
    public void setQueueManager(QueueManager queueManager) {
        this.queueManager = queueManager;
    }

    @Autowired
    public void setAggregationQueueProperties(AggregationQueueProperties aggregationQueueProperties) {
        this.aggregationQueueProperties = aggregationQueueProperties;
    }

    @PostConstruct
    public void postConstruct() {
        queueManager.setOffset(aggregationQueueProperties.getOffset());
    }

    @Override
    public Task addTask(String taskType, String targetId) {
        return queueManager.insertTask(Task.makeCode(taskType,targetId),taskType);
    }

    @Override
    public Task claimNext(String taskType) {
        return queueManager.claimNextTaskByType(taskType);
    }

    @Override
    public Task claimNext() {
        return queueManager.claimNextTask();
    }

    @Override
    public void complete(Task task) {
        queueManager.completeTask(task);
    }

    @Override
    public void complete(int taskId) {
        queueManager.completeTask(taskId);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy