-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CORE-18320 Support for a flow specific timeout on Flow Message API (#…
…1394) Support for a flow specific timeout on Flow Message API. Client can specify a flow session specific timeout on Flow Message API. If set, it will be passed to the initiated party to also use it. If the client does not provide a timeout value then the value from Corda Configuration is used. A new class FlowSessionConfiguration is introduced to store session configuration. Methods that used configuration parameter requireClose will be deprecated with another PR. Avro schema for SessionState was modified, field requireClose was removed as this value will be stored in sessionProperties.
- Loading branch information
Showing
6 changed files
with
183 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
62 changes: 62 additions & 0 deletions
62
application/src/main/java/net/corda/v5/application/messaging/FlowSessionConfiguration.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package net.corda.v5.application.messaging; | ||
|
||
import java.time.Duration; | ||
|
||
/** | ||
* Flow session configuration. Instances should be created using {@link Builder}. | ||
*/ | ||
public final class FlowSessionConfiguration { | ||
private final boolean requireClose; | ||
private final Duration timeout; | ||
|
||
private FlowSessionConfiguration(Builder builder) { | ||
this.requireClose = builder.requireClose; | ||
this.timeout = builder.timeout; | ||
} | ||
|
||
public boolean isRequireClose() { | ||
return requireClose; | ||
} | ||
|
||
public Duration getTimeout() { | ||
return timeout; | ||
} | ||
|
||
public static final class Builder { | ||
private boolean requireClose = true; | ||
private Duration timeout; | ||
|
||
/** | ||
* When set to true, the initiated party will send a close message after calling FlowSession.close() | ||
* and the initiating party will suspend and wait to receive the message when they call FlowSession.close(). | ||
* When set to false the session is marked as terminated immediately when close() is called. | ||
* Default value is true. | ||
* @param requireClose Flag that indicates whether close message is required. | ||
* @return {@link Builder}. | ||
*/ | ||
public Builder requireClose(boolean requireClose) { | ||
this.requireClose = requireClose; | ||
return this; | ||
} | ||
|
||
/** | ||
* The duration that Corda waits when no message has been received from a counterparty before | ||
* causing the session to error. If set to null, value set in Corda Configuration will be used. | ||
* Default value is null. | ||
* @param timeout Session timeout. | ||
* @return {@link Builder}. | ||
*/ | ||
public Builder timeout(Duration timeout) { | ||
this.timeout = timeout; | ||
return this; | ||
} | ||
|
||
/** | ||
* Builds a new instance of {@link FlowSessionConfiguration}. | ||
* @return a new instance of {@link FlowSessionConfiguration}. | ||
*/ | ||
public FlowSessionConfiguration build() { | ||
return new FlowSessionConfiguration(this); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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