Interface NotificationState

  • All Superinterfaces:
    Serializable
    All Known Subinterfaces:
    EntityAwareNotificationState

    public interface NotificationState
    extends Serializable
    Keep track of message bus notification of state change of a 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:
    NotificationStateAware, NotificationManager, RetryHandler
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getAttempts()
      The number of times the system has attempted sending a message for this state change.
      Instant getChangeTimestamp()
      Retrieve the last time this entity was updated in a way that requires notification via a message bus.
      Instant getChangeTimestampAck()
      Retrieve the last time a message was sent for a state change to the message bus.
      String getMessageType()
      The fully qualified Type for the message information
      String getMessageValue()
      If message serialization is used, this is the JSON string version of the message information
      String getName()
      The name identifying this particular message state.
      Instant getNextAttempt()
      The time at which (or beyond which) another retry attempt should be made
      boolean isAcked()
      Whether or not this state has been acknowledged as successfully being sent to the message broker
      boolean isStopped()
      Whether or not retry attempts should cease for this state
      void setAcked​(boolean acked)
      Whether or not this state has been acknowledged as successfully being sent to the message broker
      void 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 qualified Type for the message information
      void setMessageValue​(String messageValue)
      If message serialization is used, this is the JSON string version of the message information
      void setName​(String name)
      The name identifying this particular message state.
      void setNextAttempt​(Instant nextAttempt)
      The time at which (or beyond which) another retry attempt should be made
      void setStopped​(boolean stopped)
      Whether or not retry attempts should cease for this state
    • Method Detail

      • 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 the getChangeTimestampAck() 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 qualified Type 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

        void setChangeTimestamp​(Instant timestamp)
        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 the getChangeTimestampAck() 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

        void setChangeTimestampAck​(Instant timestampAck)
        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

        void setNextAttempt​(Instant nextAttempt)
        The time at which (or beyond which) another retry attempt should be made
      • setName

        void setName​(String name)
        The name identifying this particular message state.
        Parameters:
        name - The name identifying this particular message state.
      • setMessageValue

        void setMessageValue​(String messageValue)
        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

        void setMessageType​(String type)
        The fully qualified Type for the message information