当前位置: 首页>>代码示例>>Java>>正文


Java ActivityExecutionContext类代码示例

本文整理汇总了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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:CamelActivityImplementation.java

示例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) {

    }

}
 
开发者ID:pedropaulovc,项目名称:aws-flow-maven-eclipse-samples,代码行数:17,代码来源:CommonRecipeActivitiesImpl.java

示例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;
}
 
开发者ID:soofaloofa,项目名称:swf-starter,代码行数:16,代码来源:S3StorageActivities.java

示例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;
}
 
开发者ID:pedropaulovc,项目名称:aws-flow-maven-eclipse-samples,代码行数:10,代码来源:HumanTaskActivitiesImpl.java

示例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);
}
 
开发者ID:pedropaulovc,项目名称:aws-flow-maven-eclipse-samples,代码行数:15,代码来源:CronExampleActivitiesImpl.java

示例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);
}
 
开发者ID:pedropaulovc,项目名称:aws-flow-maven-eclipse-samples,代码行数:11,代码来源:CronExampleActivitiesImpl.java

示例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");
    }
}
 
开发者ID:pedropaulovc,项目名称:aws-flow-maven-eclipse-samples,代码行数:16,代码来源:CronWithRetryWorkflowTest.java

示例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++;
}
 
开发者ID:pedropaulovc,项目名称:aws-flow-maven-eclipse-samples,代码行数:13,代码来源:CronWorkflowTest.java

示例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++;
}
 
开发者ID:pedropaulovc,项目名称:aws-flow-maven-eclipse-samples,代码行数:14,代码来源:PeriodicWorkflowTest.java


注:本文中的com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。