47 lines
1.2 KiB
Java
47 lines
1.2 KiB
Java
package de.hottis.measurementCollector;
|
|
|
|
import de.hottis.common.HottisCommonException;
|
|
import de.hottis.common.MyQueue;
|
|
import de.hottis.smarthomelib.ADataObject;
|
|
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 final String topic;
|
|
private final 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 HottisCommonException {
|
|
for (ADataObject ado : itemList) {
|
|
enqueue(ado);
|
|
}
|
|
}
|
|
|
|
public void enqueue(ADataObject item) throws HottisCommonException {
|
|
queue.enqueue(item);
|
|
logger.debug("message enqueued");
|
|
}
|
|
|
|
abstract public void execute(LocalDateTime timestamp, String msgPayload);
|
|
}
|