class MessagePublisher implements AutoCloseable {

	public synchronized void close() {
		LoggingService.logDebug(MODULE_NAME, "Start closing publish");
		try {
			archive.close();
		} catch (Exception exp) {
			logError(MODULE_NAME, "Error closing message archive", new AgentSystemException(exp.getMessage(), exp));
		}

		if (producers != null && producers.size() > 0) {
			for (MessageProducer producer: producers) {
				try {
					producer.close();
				} catch (Exception exp) {
					logError(MODULE_NAME, "Error closing message publisher", new AgentSystemException(exp.getMessage(), exp));
				}
			}
			producers.clear();
		}

		LoggingService.logDebug(MODULE_NAME, "Finished closing publish");
	}

	public  MessagePublisher(String name, Route route, List<MessageProducer> producers);

}