-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
safe message passing sample #681
safe message passing sample #681
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, all looks good, except I have a concern that we're doing start/stop wrong in all our samples (except Go?).
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you educate me on why we convert the one exception into the other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InterruptedException
is a checked exception so we need to translate it to a unchecked exception
// to make it easier to pass between runs | ||
class ClusterManagerState { | ||
public boolean clusterStarted; | ||
public boolean clusterShutdown; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are mutually exclusive -- can we use an enum for them? (Also as booleans would it be more idiomatic in java for them to start with is
or does that only apply to methods?)
|
||
@Override | ||
public void stopCluster() { | ||
Workflow.await(() -> state.clusterStarted); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if someone sends the stop signal by mistake, it will just hang, and then the next time they start the cluster it will suddenly stop. That seems undesirable. That suggests this should be an update, so we can return success/fail.
(It's the same in the other non-Go languages)
} | ||
|
||
@Override | ||
public void startCluster() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to check that the cluster's in an appropriate state to proceed to the next lines. That suggests this should be an update, so we can return success/fail.
(If so it's a bug in the other non-Go languages)
core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowImpl.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowImpl.java
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowImpl.java
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflow.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflow.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflow.java
Outdated
Show resolved
Hide resolved
cba8ce2
to
52226ac
Compare
@dandavison thanks for the feedback, I updated the sample based on what you did in TS |
core/src/main/java/io/temporal/samples/safemessagepassing/ClusterManagerWorkflowImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…terManagerWorkflowImpl.java Co-authored-by: Dan Davison <[email protected]>
Add safe message passing sample.
Code based on https://github.com/temporalio/samples-python/tree/main/message_passing/safe_message_handlers