package de.hottis.measurementCollector;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Properties;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public abstract class AMessageParser {
	final protected Logger logger = LogManager.getRootLogger();

	private String topic;
	private MyQueue<ADataObject> queue;
	protected Properties config;

	public AMessageParser(String topic, Properties config, MyQueue<ADataObject> queue) {
		this.topic = topic;
		this.config = config;
		this.queue = queue;
	}

	public void init() throws MeasurementCollectorException {
	}


	public String getTopic() {
		return this.topic;
	}

	public void enqueue(List<ADataObject> itemList) throws MeasurementCollectorException {
		for (ADataObject ado : itemList) {
			queue.enqueue(ado);
			logger.debug("message enqueued");
		}
	}

	abstract public void execute(LocalDateTime timestamp, String msgPayload);
}
