run workflow

This commit is contained in:
Peter Nham
2020-07-20 17:02:14 +10:00
parent 02bbaa47f5
commit 3813ddfdaf
4 changed files with 32 additions and 12 deletions
+3 -1
View File
@@ -1 +1,3 @@
.idea
.idea
build
.gradle
@@ -1,7 +0,0 @@
package com.afterpay.ds.cadence;
import com.uber.cadence.worker.Worker;
public class App {
}
@@ -14,14 +14,14 @@ public class HelloCadence {
private static Logger logger = Workflow.getLogger(HelloCadence.class);
public static void main(String[] args) {
Worker.Factory factory = new Worker.Factory("localhost",7933, "test-domain-au");
Worker worker = factory.newWorker("aaa");
Worker.Factory factory = new Worker.Factory("192.168.0.249",7933, "domain");
Worker worker = factory.newWorker("helloWorldTaskList");
worker.registerWorkflowImplementationTypes(HelloWorldImpl.class);
factory.start();
}
public interface HelloWorld {
@WorkflowMethod
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 60, taskList = "helloWorldTaskList")
void sayHello(String name);
@SignalMethod
@@ -45,7 +45,7 @@ public class HelloCadence {
// }
// logger.info(++count + ": " + greeting + " " + name + "!");
Workflow.sleep(Duration.ofSeconds(30));
Workflow.sleep(Duration.ofSeconds(10));
logger.info(++count + ": " + greeting + " " + name + "!");
}
@@ -0,0 +1,25 @@
package com.afterpay.ds.cadence;
import com.afterpay.ds.cadence.HelloCadence.HelloWorld;
import com.uber.cadence.WorkflowExecution;
import com.uber.cadence.client.WorkflowClient;
public class StartWorkflow {
public static void main(String[] args) throws InterruptedException {
WorkflowClient workflowClient = WorkflowClient.newInstance("192.168.0.249", 7933, "domain");
for (int i = 0; i < 100; i++) {
// Create a workflow stub.
HelloWorld workflow = workflowClient.newWorkflowStub(HelloWorld.class);
// Returns as soon as the workflow starts.
WorkflowExecution workflowExecution = WorkflowClient.start(workflow::sayHello, args[0] + i);
System.out.println("Started process file workflow with workflowId=\"" + workflowExecution.getWorkflowId() + "\" and runId=\"" + workflowExecution.getRunId() + "\"");
}
System.exit(0);
}
}