Interface NotificationState
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
EntityAwareNotificationState
NotificationStateAware
entity. Some persistence operations require reliable notification of a message bus of that state
change. This structure holds message bus send acknowledgement and retry attempt information to
help govern a system that retries message sending should the initial send fail for some reason
(e.g. the message broker happened to be down).
Systems honoring this contract should be designed such that cumulative messages are allowed. For
example, a change may be persisted and a message send fails. Then another change is persisted on
top of the first. At this point, the message succeeds. In this case, the system should expect to
send a message that notifies the cumulative state change, including both the first and second
changes. This only applies to state that does not include the getMessageValue()
(and
associated fields). State that contains message value will always use that message value to
reconstitute the message to send on retry. The caveat here is that if the state continues to
change, message value could be lost. For this reason, flows that utilize message value should
prevent further update until the state is acknowledged, or fails maximum attempts.
- Author:
- Jeff Fischer
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
The number of times the system has attempted sending a message for this state change.Retrieve the last time this entity was updated in a way that requires notification via a message bus.Retrieve the last time a message was sent for a state change to the message bus.default String
getId()
The persisted representation of aNotificationState
typically has its own globally unique identifier.The fully qualifiedType
for the message informationIf message serialization is used, this is the JSON string version of the message informationgetName()
The name identifying this particular message state.The time at which (or beyond which) another retry attempt should be madeboolean
isAcked()
Whether or not this state has been acknowledged as successfully being sent to the message brokerboolean
Whether or not retry attempts should cease for this statevoid
setAcked
(boolean acked) Whether or not this state has been acknowledged as successfully being sent to the message brokervoid
setAttempts
(int attempts) The number of times the system has attempted sending a message for this state change.void
setChangeTimestamp
(Instant timestamp) Set the last time this entity was updated in a way that requires notification via a message bus.void
setChangeTimestampAck
(Instant timestampAck) Set the last time a message was sent for a state change to the message bus.void
setMessageType
(String type) The fully qualifiedType
for the message informationvoid
setMessageValue
(String messageValue) If message serialization is used, this is the JSON string version of the message informationvoid
The name identifying this particular message state.void
setNextAttempt
(Instant nextAttempt) The time at which (or beyond which) another retry attempt should be madevoid
setStopped
(boolean stopped) Whether or not retry attempts should cease for this state
-
Method Details
-
getChangeTimestamp
Instant getChangeTimestamp()Retrieve the last time this entity was updated in a way that requires notification via a message bus. The system independently monitors this value against thegetChangeTimestampAck()
to confirm that the change message was successfully sent via the producer. If the ack is null, or less than the change timestamp, the system should take action to send the message again.- Returns:
- The last time this entity was updated
-
getChangeTimestampAck
Instant getChangeTimestampAck()Retrieve the last time a message was sent for a state change to the message bus.- Returns:
- The last time a message was sent
-
getAttempts
int getAttempts()The number of times the system has attempted sending a message for this state change.- Returns:
- The number of times the system has attempted sending a message
-
getNextAttempt
Instant getNextAttempt()The time at which (or beyond which) another retry attempt should be made- Returns:
- The time at which (or beyond which) another retry attempt should be made
-
isAcked
boolean isAcked()Whether or not this state has been acknowledged as successfully being sent to the message broker- Returns:
- Whether or not this state has been acknowledged
-
getName
String getName()The name identifying this particular message state.- Returns:
- The name identifying this particular message state.
-
getMessageValue
String getMessageValue()If message serialization is used, this is the JSON string version of the message information- Returns:
- the JSON string version of the message information
-
getMessageType
String getMessageType()The fully qualifiedType
for the message information- Returns:
- The fully qualified
Type
for the message information
-
isStopped
boolean isStopped()Whether or not retry attempts should cease for this state- Returns:
- Whether or not retry attempts should cease for this state
-
setChangeTimestamp
Set the last time this entity was updated in a way that requires notification via a message bus. The system independently monitors this value against thegetChangeTimestampAck()
to confirm that the change message was successfully sent via the producer. If the ack is null, or less than the change timestamp, the system should take action to send the message again.- Parameters:
timestamp
- The last time this entity was updated
-
setChangeTimestampAck
Set the last time a message was sent for a state change to the message bus.- Parameters:
timestampAck
- The last time a message was sent
-
setAttempts
void setAttempts(int attempts) The number of times the system has attempted sending a message for this state change. -
setAcked
void setAcked(boolean acked) Whether or not this state has been acknowledged as successfully being sent to the message broker -
setNextAttempt
The time at which (or beyond which) another retry attempt should be made -
setName
The name identifying this particular message state.- Parameters:
name
- The name identifying this particular message state.
-
setMessageValue
If message serialization is used, this is the JSON string version of the message information -
setStopped
void setStopped(boolean stopped) Whether or not retry attempts should cease for this state -
setMessageType
The fully qualifiedType
for the message information -
getId
The persisted representation of aNotificationState
typically has its own globally unique identifier. This method should expose that value, if available. Implementations are strongly encouraged to support this method, as having a unique ID forNotificationState
can help disambiguate between instances.- Returns:
- the globally unique identifier for this
NotificationState
-