일부 활동이 있으며 사용자 정의 예외가 발생할 수 있습니다. 문제는 Activity Worker 클래스에서 throw 된 예외를 catch 할 수 없어 스택 추적이 표시되고 있다는 것입니다. Throwable을 잡으려고했지만 스택 추적이 다시 표시되는 것처럼 유용하지 않습니다.활동 작업자 클래스에서 예외를 catch 할 수 없습니다.
활동 구현 클래스
public class TestActivitiesImpl implements TestActivities{
@Override
public Integer testAct1() {
System.out.println("Activity 1 ---->Start");
int count = 0;
while(count < 1000){
count ++;
}
return 1;
}
@SuppressWarnings("unused")
@Override
public Integer testAct2() throws MyException {
System.out.println("Activity 2 ---->Start");
if(true){
throw new MyException("Failed to execute the activity");
}
return 1;
}
}
활동 노동자 클래스
public class TestActivitiesWorker {
public static void main(String[] args) {
try {
ClientConfiguration config = new ClientConfiguration().withSocketTimeout(70*1000);
String swfAccessId = "ABCDXYZ";
String swfSecretKey = "ABCDXYZ";
AWSCredentials awsCredentials = new BasicAWSCredentials(swfAccessId, swfSecretKey);
AmazonSimpleWorkflow service = new AmazonSimpleWorkflowClient(awsCredentials, config);
service.setEndpoint("ABCDXYZ");
String domain = "EC2-TEST";
ActivityWorker aw = new ActivityWorker(service, domain, "TestList");
aw.addActivitiesImplementation(new TestActivitiesImpl());
aw.start();
}catch (Throwable e) {
System.out.println("Failed to execute Job");
System.out.println(e.getMessage());
}
}
}
스택 추적
2014년 10월 18일 오후 2시 2분 53초
com.amazonaws.services.simpleworkflow.flow.worker.SynchronousActivityTaskPoller execute
SEVERE: Failure processing activity task with taskId=12, workflowGenerationId=AsyncTest, activity={Name: TestActivities.testAct2,Version: 1.2}, activityInstanceId=2
com.amazonaws.services.simpleworkflow.flow.ActivityFailureException: Failed to execute the activity : ["com.myapp.test.MyException",{"cause":null,"stackTrace":[{"methodName":"testAct2","fileName":"TestActivitiesImpl.java","lineNumber":20,"className":"com.myapp.test.TestActivitiesImpl","nativeMethod":false},{"methodName":"invoke0","fileName":"NativeMethodAccessorImpl.java","lineNumber":-2,"className":"sun.reflect.NativeMethodAccessorImpl","nativeMethod":true},{"methodName":"invoke","fileName":"NativeMethodAccessorImpl.java","lineNumber":57,"className":"sun.reflect.NativeMethodAccessorImpl","nativeMethod":false},{"methodName":"invoke","fileName":"DelegatingMethodAccessorImpl.java","lineNumber":43,"className":"sun.reflect.DelegatingMethodAccessorImpl","nativeMethod":false},{"methodName":"invoke","fileName":"Method.java","lineNumber":606,"className":"java.lang.reflect.Method","nativeMethod":false},{"methodName":"execute","fileName":"POJOActivityImplementation.java","lineNumber":64,"className":"com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementation","nativeMethod":false},{"methodName":"execute","fileName":"ActivityImplementationBase.java","lineNumber":46,"className":"com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationBase","nativeMethod":false},{"methodName":"execute","fileName":"SynchronousActivityTaskPoller.java","lineNumber":196,"className":"com.amazonaws.services.simpleworkflow.flow.worker.SynchronousActivityTaskPoller","nativeMethod":false},{"methodName":"run","fileName":"ActivityTaskPoller.java","lineNumber":92,"className":"com.amazonaws.services.simpleworkflow.flow.worker.ActivityTaskPoller$2","nativeMethod":false},{"methodName":"runWorker","fileName":"ThreadPoolExecutor.java","lineNumber":1145,"className":"java.util.concurrent.ThreadPoolExecutor","nativeMethod":false},{"methodName":"run","fileName":"ThreadPoolExecutor.java","lineNumber":615,"className":"java.util.concurrent.ThreadPoolExecutor$Worker","nativeMethod":false},{"methodName":"run","fileName":"Thread.java","lineNumber":724,"className":"java.lang.Thread","nativeMethod":false}],"message":"Failed to execute the activity","localizedMessage":"Failed to execute the activity","suppressed":["[Ljava.lang.Throwable;",[]]}]
at com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementation.throwActivityFailureException(POJOActivityImplementation.java:110)
at com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementation.execute(POJOActivityImplementation.java:67)
at com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationBase.execute(ActivityImplementationBase.java:46)
at com.amazonaws.services.simpleworkflow.flow.worker.SynchronousActivityTaskPoller.execute(SynchronousActivityTaskPoller.java:196)
at com.amazonaws.services.simpleworkflow.flow.worker.ActivityTaskPoller$2.run(ActivityTaskPoller.java:92)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
스택 추적을 표시 할 수 있습니까? – ToYonos
예, 확실하게 .. 스택 추적을 게시했습니다 – Rahul