String domain = configHelper.getDomain();
String localFolder = configHelper.getValueFromConfig(FileProcessingConfigKeys.ACTIVITY_WORKER_LOCALFOLDER);
// Start worker to poll the common task list
final ActivityWorker workerForCommonTaskList = new ActivityWorker(swfService, domain, ACTIVITIES_TASK_LIST);
SimpleStoreActivitiesS3Impl storeActivityImpl = new SimpleStoreActivitiesS3Impl(s3Client, localFolder, getHostName());
workerForCommonTaskList.addActivitiesImplementation(storeActivityImpl);
workerForCommonTaskList.start();
System.out.println("Host Service Started for Task List: " + ACTIVITIES_TASK_LIST);
// Start worker to poll the host specific task list
final ActivityWorker workerForHostSpecificTaskList = new ActivityWorker(swfService, domain, getHostName());
workerForHostSpecificTaskList.addActivitiesImplementation(storeActivityImpl);
FileProcessingActivitiesZipImpl processorActivityImpl = new FileProcessingActivitiesZipImpl(localFolder);
workerForHostSpecificTaskList.addActivitiesImplementation(processorActivityImpl);
workerForHostSpecificTaskList.start();
System.out.println("Worker Started for Activity Task List: " + getHostName());
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
workerForCommonTaskList.shutdown();
workerForHostSpecificTaskList.shutdown();
workerForCommonTaskList.awaitTermination(1, TimeUnit.MINUTES);
workerForHostSpecificTaskList.awaitTermination(1, TimeUnit.MINUTES);
System.out.println("Activity Workers Exited.");
}
catch (InterruptedException e) {
e.printStackTrace();
}