package de.hottis.measurementCollector;

import java.util.Properties;

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


public class MeasurementCollector {
	static final String PROPS_FILENAME = "measurementCollector.props";
	static final Logger logger = LogManager.getRootLogger();
	
	
	public static void main(String[] args) throws Exception {
		logger.info("MeasurementCollector starting");
		
		final Properties config = new Properties();
		config.load(MeasurementCollector.class.getClassLoader().getResourceAsStream(PROPS_FILENAME));
		logger.debug("Configuration loaded");
		
		MqttReceiver mqttReceiver = new MqttReceiver(config);
		mqttReceiver.connect();
		logger.debug("MqttReceiver started");
		
		JmsTopic<ADataObject> queue = new JmsTopic<ADataObject>(config, JmsTopic.Mode.PRODUCER); 
		queue.init();
		
		MBusParser mbusParser = new MBusParser(config, queue);
		mbusParser.init();
		mbusParser.registerConfiguredDataParsers();
		mqttReceiver.registerParser(mbusParser);
		logger.debug("MBusParser started");
	}
		
}
