-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTutorialActivities.java
37 lines (32 loc) · 1.45 KB
/
TutorialActivities.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package io.temporal.learning;
import java.io.*;
import java.time.Duration;
import io.temporal.activity.*;
@ActivityInterface
public interface TutorialActivities {
// Vended activities.
public void doSomethingFirst(String input);
public void doSomethingSecond(String input);
public ActivityOptions quickActivityOptions = ActivityOptions
.newBuilder()
.setStartToCloseTimeout(Duration.ofSeconds(12)) // Max Activity execution time only
.setScheduleToCloseTimeout(Duration.ofSeconds(120)) // Entire duration from scheduling to completion, including queue time.
.build();
// Implement the vended activities, normally externally
public static class TutorialActivitiesImpl implements TutorialActivities {
@Override
public void doSomethingFirst(String input) {
System.out.println("Starting Activity 1");
try { Thread.sleep(8000); } // sleep for a few seconds
catch (InterruptedException e) { e.printStackTrace(); }
System.out.println("Finished first activity. Processed " + input);
}
@Override
public void doSomethingSecond(String input) {
System.out.println("Starting Activity 2");
try { Thread.sleep(8000); } // sleep for a few seconds
catch (InterruptedException e) { e.printStackTrace(); }
System.out.println("Finished second activity. Processed " + input);
}
}
}