Last active
January 2, 2016 22:38
-
-
Save qrtt1/8370792 to your computer and use it in GitHub Desktop.
利用 AWS Simple Workflow Service 把一組商業流程包起來,這是個微行 Framework 的試作品。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.logging.Log; | |
import org.apache.commons.logging.LogFactory; | |
import org.qty.aws.swf.annotation.DeciderConfig; | |
import org.qty.aws.swf.contract.AbstractDecision; | |
@DeciderConfig(domain = "WorkflowLab-20140109a", taskList = "paid-video-queue") | |
public class ChannelProcessDecider extends AbstractDecision { | |
static Log logger = LogFactory.getLog(ChannelProcessWorkflow.class); | |
private static final String INITIAL_STATE = null; | |
@Override | |
public void nextActivity(String activityType, String data) { | |
if (activityType == INITIAL_STATE) { | |
logger.warn("no activity-type found"); | |
to(CheckImageUrlActivity.class); | |
} | |
ProcessState state = ProcessState.fromJsonString(data); | |
if (!state.isValid() | |
|| state.getReturnState() != ReturnState.COMPLETED) { | |
terminateWithFailure("something wrong with the result data", ""); | |
} | |
// 1. check-image-url | |
if (onFinish(CheckImageUrlActivity.class, activityType)) { | |
to(CheckS3VideoUrlActivity.class); | |
} | |
// 2. check the video on s3 is playable | |
if (onFinish(CheckS3VideoUrlActivity.class, activityType)) { | |
to(VideoSyncActivity.class); | |
} | |
// 3. sync video from s3 to azure storage | |
if (onFinish(VideoSyncActivity.class, activityType)) { | |
to(ProvisionActivity.class); | |
} | |
// 4. provisioning channel data | |
if (onFinish(ProvisionActivity.class, activityType)) { | |
logger.info("final state !!!"); | |
finish(); | |
} | |
terminateWithFailure("undefined behavior", "no matched next-activities"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment