in src/sample/SampleApp.java [27:71]
public static void main(String[] args) throws InterruptedException{
final Log logger = LogFactory.getLog(SampleApp.class);
//create AWSCloudTrailProcessingExecutor and start it
final AWSCloudTrailProcessingExecutor executor = new AWSCloudTrailProcessingExecutor
.Builder(new SampleEventsProcessor(), "/sample/awscloudtrailprocessinglibrary.properties")
.withSourceFilter(new SampleSourceFilter())
.withEventFilter(new SampleEventFilter())
.withProgressReporter(new SampleProgressReporter())
.withExceptionHandler(new SampleExceptionHandler())
.build();
executor.start();
// add shut down hook to gracefully stop executor (optional)
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
logger.info("Shut Down Hook is called.");
executor.stop();
}
});
// register a Default Uncaught Exception Handler (optional)
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
logger.error("Handled by global Exception handler. " + e.getMessage() + " " + t.getName());
//Two options here:
//First, we can call System.exit(1); in such case shut down hook will be called.
//Second, we can optionally restart another executor and start.
final AWSCloudTrailProcessingExecutor executor = new AWSCloudTrailProcessingExecutor
.Builder(new SampleEventsProcessor(), "/sample/awscloudtrailprocessinglibrary.properties")
.withSourceFilter(new SampleSourceFilter())
.withEventFilter(new SampleEventFilter())
.withProgressReporter(new SampleProgressReporter())
.withExceptionHandler(new SampleExceptionHandler())
.build();
executor.start();
}
});
//can optionally limit running time, or remove both lines so it is running forever. (optional)
Thread.sleep(24 * 60 * 60 *1000);
executor.stop();
}