com.networknt.eventuate.cdc.server.CdcServerShutdownHookProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eventuate-cdc-server Show documentation
Show all versions of eventuate-cdc-server Show documentation
A restful micro service server component of change data capture.
package com.networknt.eventuate.cdc.server;
import com.networknt.eventuate.server.common.EventTableChangesToAggregateTopicTranslator;
import com.networknt.eventuate.server.common.PublishedEvent;
import com.networknt.server.ShutdownHookProvider;
import com.networknt.service.SingletonServiceFactory;
import org.apache.curator.framework.CuratorFramework;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* cDc service ShutdownHookProvider, stop cDc service
*/
public class CdcServerShutdownHookProvider implements ShutdownHookProvider {
private static final Logger logger = LoggerFactory.getLogger(CdcServerShutdownHookProvider.class);
public void onShutdown() {
EventTableChangesToAggregateTopicTranslator translator = SingletonServiceFactory.getBean(EventTableChangesToAggregateTopicTranslator.class);
if(translator != null) {
try {
translator.stop();
} catch (Exception e) {
logger.error("Exception: ", e);
}
}
CuratorFramework curatorFramework = SingletonServiceFactory.getBean(CuratorFramework.class);
if(curatorFramework != null) {
curatorFramework.close();
}
logger.info("CdcServerShutdownHookProvider is called");
}
}