Class JdbcTokenEntry
java.lang.Object
org.axonframework.messaging.eventhandling.processing.streaming.token.store.jdbc.JdbcTokenEntry
Jdbc class of an entry containing a serialized tracking token belonging to a given process. For use with
Jakarta/Hibernate 6 use
TokenEntry instead.- Since:
- 3.0.0
- Author:
- Rene de Waele, Simon Zambrovski
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor required for JPAJdbcTokenEntry(byte[] token, String tokenType, String timestamp, String owner, String processorName, Segment segment) Initializes a token entry from existing data.JdbcTokenEntry(TrackingToken token, Converter converter) Initializes a new token entry for giventoken,processandsegment. -
Method Summary
Modifier and TypeMethodDescriptionbooleanclaim(String owner, TemporalAmount claimTimeout) Attempt to claim ownership of this token.getOwner()Returns the identifier of the process (JVM) having a claim on this token, ornullif the token isn't claimed.Returns the name of theStreamingEventProcessorto which this token belongs.Returns the segment of this token.Returns the token, deserializing it with givenconverter.byte[]Retrieves serialized value of the token.Retrieves token type.booleanmayClaim(String owner, TemporalAmount claimTimeout) Check if givenownermay claim this token.booleanreleaseClaim(String owner) Release any claim of ownership currently active on this Token, if owned by the givenowner.Returns the storage timestamp of this token entry.Returns the storage timestamp of this token entry as a String.final voidupdateToken(TrackingToken token, Converter converter) Update the token data to the giventoken, using givenconverterto serialize it to bytes[].
-
Field Details
-
clock
The clock used to persist timestamps in this entry. Defaults to UTC system time.
-
-
Constructor Details
-
JdbcTokenEntry
Initializes a new token entry for giventoken,processandsegment. The givenconvertercan be used to serialize the token before it is stored.- Parameters:
token- The tracking token to store.converter- The converter to use when storing a serialized token.
-
JdbcTokenEntry
public JdbcTokenEntry(byte[] token, String tokenType, String timestamp, String owner, @Nonnull String processorName, @Nonnull Segment segment) Initializes a token entry from existing data.- Parameters:
token- The serialized token.tokenType- The serialized type of the token.timestamp- The timestamp of the token.owner- The owner of the token.processorName- The processor name.segment- The token segment.
-
JdbcTokenEntry
protected JdbcTokenEntry()Default constructor required for JPA
-
-
Method Details
-
getToken
Returns the token, deserializing it with givenconverter.- Parameters:
converter- The converter to deserialize the token with.- Returns:
- The deserialized token stored in this entry.
-
timestamp
Returns the storage timestamp of this token entry.- Returns:
- The storage timestamp.
-
timestampAsString
Returns the storage timestamp of this token entry as a String.- Returns:
- The storage timestamp as string.
-
getProcessorName
Returns the name of theStreamingEventProcessorto which this token belongs.- Returns:
- The name of the
StreamingEventProcessorto which this token belongs.
-
getSegment
Returns the segment of this token.- Returns:
- The segment of this token.
-
getOwner
Returns the identifier of the process (JVM) having a claim on this token, ornullif the token isn't claimed.- Returns:
- The process (JVM) that claimed this token.
-
getTokenData
public byte[] getTokenData()Retrieves serialized value of the token.- Returns:
- Returns token value as bytes.
-
getTokenType
Retrieves token type.- Returns:
- Returns token type.
-
claim
Attempt to claim ownership of this token. When successful, this method returnstrue, otherwisefalse. When a claim fails, this token should not be used, as it is already being used in another process.If a claim exists, but it is older than given
claimTimeout, the claim may be 'stolen'.- Parameters:
owner- The name of the current node, to register as owner. This name must be unique for multiple instances of the same logical processor.claimTimeout- The time after which a claim may be 'stolen' from its current owner.- Returns:
trueif the claim succeeded, otherwise false.
-
mayClaim
Check if givenownermay claim this token.- Parameters:
owner- The name of the current node, to register as owner. This name must be unique for multiple instances of the same logical processor.claimTimeout- The time after which a claim may be 'stolen' from its current owner.- Returns:
trueif the claim may be made,falseotherwise.
-
releaseClaim
Release any claim of ownership currently active on this Token, if owned by the givenowner.- Parameters:
owner- The name of the current node, which was registered as the owner.- Returns:
trueof the claim was successfully released, orfalseif the token has been claimed by another owner.
-
updateToken
Update the token data to the giventoken, using givenconverterto serialize it to bytes[].- Parameters:
token- The token representing the state to update to.converter- The converter to update token to.
-