本文整理汇总了Java中com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext类的典型用法代码示例。如果您正苦于以下问题:Java ActivityExecutionContext类的具体用法?Java ActivityExecutionContext怎么用?Java ActivityExecutionContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActivityExecutionContext类属于com.amazonaws.services.simpleworkflow.flow包,在下文中一共展示了ActivityExecutionContext类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
@Override
protected String execute(String input, ActivityExecutionContext context) throws ActivityFailureException, CancellationException {
Object[] inputParameters = converter.fromData(input, Object[].class);
CurrentActivityExecutionContext.set(context);
Object result = null;
ActivityExecutionContext executionContext = contextProvider.getActivityExecutionContext();
String taskToken = executionContext.getTaskToken();
try {
result = swfWorkflowConsumer.processActivity(inputParameters, taskToken);
} catch (InvocationTargetException invocationException) {
throwActivityFailureException(invocationException.getTargetException() != null ? invocationException.getTargetException() : invocationException);
} catch (IllegalArgumentException illegalArgumentException) {
throwActivityFailureException(illegalArgumentException);
} catch (IllegalAccessException illegalAccessException) {
throwActivityFailureException(illegalAccessException);
} catch (Exception e) {
throwActivityFailureException(e);
} finally {
CurrentActivityExecutionContext.unset();
}
String resultSerialized = converter.toData(result);
return resultSerialized;
}
示例2: delayActivity
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
@Override
public void delayActivity(long time) {
calls.add("delayActivity");
ActivityExecutionContextProvider provider = new ActivityExecutionContextProviderImpl();
ActivityExecutionContext context = provider.getActivityExecutionContext();
try {
while (true) {
Thread.sleep(time * 1000);
context.recordActivityHeartbeat(null);
}
}
catch (InterruptedException e) {
}
}
示例3: heartbeat
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
/**
* Heartbeat every 5 minutes. It is not a good idea to heartbeat too
* frequently as each noteActivityProgress event ends up eating history
* events count.
*
* @return time of the last heartbeat
*/
private long heartbeat(long lastHeartbeatTime, int progress) {
if (System.currentTimeMillis() - lastHeartbeatTime > HEARTBEAT_INTERVAL) {
ActivityExecutionContext context = contextProvider.getActivityExecutionContext();
context.recordActivityHeartbeat(Integer.toString((progress)));
lastHeartbeatTime = System.currentTimeMillis();
}
return lastHeartbeatTime;
}
示例4: humanActivity
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
@Override
@ManualActivityCompletion
public String humanActivity() {
ActivityExecutionContext executionContext = contextProvider.getActivityExecutionContext();
String taskToken = executionContext.getTaskToken();
System.out.println("Task received, completion token: " + taskToken);
//This will not be returned to the caller
return null;
}
示例5: doSomeWork
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
/**
* Fail in 20% of invocations to demonstrate retry logic
*/
@Override
public void doSomeWork(String parameter) {
Random r = new Random();
if (r.nextInt(100) < 20) {
throw new RuntimeException("simulated exception to force retry");
}
ActivityExecutionContext context = contextProvider.getActivityExecutionContext();
ActivityTask task = context.getTask();
String taskid = task.getActivityId();
System.out.println("Processed activity task with id: " + taskid);
}
示例6: heartbeat
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
/**
* Heartbeat every 5 minutes. It is not a good idea to heartbeat too
* frequently as each noteActivityProgress event ends up eating history
* events count.
*
* @return time of the last heartbeat
*/
private long heartbeat(long lastHeartbeatTime, int progress) {
if (System.currentTimeMillis() - lastHeartbeatTime > HEARTBEAT_INTERVAL) {
ActivityExecutionContext context = contextProvider.getActivityExecutionContext();
context.recordActivityHeartbeat(Integer.toString((progress)));
lastHeartbeatTime = System.currentTimeMillis();
}
return lastHeartbeatTime;
}
开发者ID:pedropaulovc,项目名称:aws-flow-maven-eclipse-samples,代码行数:16,代码来源:SimpleStoreActivitiesS3Impl.java
示例7: doSomeWork
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
/**
*
*/
@Override
public void doSomeWork(String parameter) {
ActivityExecutionContext context = contextProvider.getActivityExecutionContext();
ActivityTask task = context.getTask();
String taskid = task.getActivityId();
System.out.println("Processed activity task with id: " + taskid);
}
示例8: doSomeWork
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
@Override
public void doSomeWork(String parameter) {
// Reset counter on the new run which changes when workflow continues as new
ActivityExecutionContext activityExecutionContext = contextProvider.getActivityExecutionContext();
WorkflowExecution workflowExecution = activityExecutionContext.getWorkflowExecution();
String runId = workflowExecution.getRunId();
if (this.runId == null || !runId.equals(this.runId)) {
runCount++;
}
this.runId = runId;
workCount++;
if (workCount % 2 != 0) {
throw new RuntimeException("simulated failure to cause retry");
}
}
示例9: doSomeWork
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
@Override
public void doSomeWork(String parameter) {
// Reset counter on the new run which changes when workflow continues as new
ActivityExecutionContext activityExecutionContext = contextProvider.getActivityExecutionContext();
WorkflowExecution workflowExecution = activityExecutionContext.getWorkflowExecution();
String runId = workflowExecution.getRunId();
if (this.runId == null || !runId.equals(this.runId)) {
runCount++;
}
this.runId = runId;
workCount++;
}
示例10: doSomeWork
import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; //导入依赖的package包/类
@Override
public void doSomeWork(String parameter) {
// Reset counter on the new run which changes when workflow continues as new
ActivityExecutionContext activityExecutionContext = contextProvider.getActivityExecutionContext();
WorkflowExecution workflowExecution = activityExecutionContext.getWorkflowExecution();
String runId = workflowExecution.getRunId();
if (this.runId != null && !runId.equals(this.runId)) {
currentRunWorkCount = 0;
}
this.runId = runId;
workCount++;
currentRunWorkCount++;
}