Skip to content

Commit d75bba3

Browse files
authored
registerWorkflowImplementationTypes fix (#114)
* registerWorkflowImplementationTypes fix * README fix
1 parent 0177dbf commit d75bba3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,18 @@ Sometimes an activity lifecycle goes beyond a synchronous method invocation. For
173173
and later a reply comes and picked up by a different worker process. The whole such request-reply interaction can be modeled
174174
as a single Cadence activity.
175175

176-
To indicate that an activity should not be completed upon its method return annotate it with @DoNotCompleteOnReturn.
176+
To indicate that an activity should not be completed upon its method return call Activity.doNotCompleteOnReturn() from the
177+
original activity thread.
177178
Then later when replies come complete it using [ActivityCompletionClient](src/main/java/com/uber/cadence/client/ActivityCompletionClient.java).
178179
To correlate activity invocation with completion use either `TaskToken` or workflow and activity ids.
179180
```java
180181
public class FileProcessingActivitiesImpl implements FileProcessingActivities {
181182

182-
@DoNotCompleteOnReturn
183183
public String download(String bucketName, String remoteName, String localName) {
184184
byte[] taskToken = Activity.getTaskToken(); // Used to correlate reply
185185
asyncDownloadFileFromS3(taskToken, bucketName, remoteName, localDirectory + localName);
186-
return "ignored"; // Return value is ignored when annotated with @DoNotCompleteOnReturn
186+
Activity.doNotCompleteOnReturn();
187+
return "ignored"; // Return value is ignored when doNotCompleteOnReturn was called.
187188
}
188189
...
189190
}

src/main/java/com/uber/cadence/worker/Worker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ private SingleWorkerOptions toWorkflowOptions(WorkerOptions options) {
148148
* </p>
149149
*/
150150
public void registerWorkflowImplementationTypes(Class<?>... workflowImplementationClasses) {
151+
if (workflowWorker == null) {
152+
throw new IllegalStateException("disableWorkflowWorker is set in worker options");
153+
}
154+
checkNotStarted();
151155
workflowWorker.setWorkflowImplementationTypes(workflowImplementationClasses);
152156
}
153157

0 commit comments

Comments
 (0)