Class NATSStreamingNotificationReceiver

    • Field Detail

      • TRACKING_FILE_NAME_PROPERTY

        public static java.lang.String TRACKING_FILE_NAME_PROPERTY
        Property for tracking file name
      • UPDATE_SEQUENCE_AFTER_EXCEPTION_PROPERTY

        public static java.lang.String UPDATE_SEQUENCE_AFTER_EXCEPTION_PROPERTY
        Property on if update sequence should occur after exception
      • SEQUENCE_PROPERTY

        public static java.lang.String SEQUENCE_PROPERTY
        Property for sequence
      • DEFAULT_TRACKING_FILE_NAME_PROPERTY

        public static java.lang.String DEFAULT_TRACKING_FILE_NAME_PROPERTY
        Name of deafult tracking file
      • DEFAULT_UPDATE_SEQUENCE_AFTER_EXCEPTION_PROPERTY

        public static java.lang.String DEFAULT_UPDATE_SEQUENCE_AFTER_EXCEPTION_PROPERTY
        Default state of update after exception
    • Constructor Detail

      • NATSStreamingNotificationReceiver

        public NATSStreamingNotificationReceiver()
    • Method Detail

      • configure

        public void configure​(Config config)
                       throws java.lang.Exception
        Configures receiver based on included properties
        Specified by:
        configure in interface Configurable
        Overrides:
        configure in class DefaultNotificationReceiver
        Parameters:
        config - The user-defined configuration
        Throws:
        java.lang.Exception - If required properties are ignored
      • startup

        public void startup()
                     throws java.lang.Exception
        Does initial tracking file management and subscribes to server With a tracking file, gets the last sequence
        Specified by:
        startup in interface Configurable
        Overrides:
        startup in class DefaultNotificationReceiver
        Throws:
        java.lang.InterruptedException - if interrupted
        java.io.IOException - if IO error occurs
        java.lang.Exception - if exceptions occur while starting.
      • shutdown

        public void shutdown()
                      throws java.lang.Exception
        Closes subscription/connection and writes state in tracking file Wraps each statement in a try/catch to ensure each step still happens
        Specified by:
        shutdown in interface Configurable
        Overrides:
        shutdown in class DefaultNotificationReceiver
        Throws:
        java.io.IOException - if IO error occurs
        java.lang.InterruptedException - if interrupted
        java.util.concurrent.TimeoutException - if timeout
        java.lang.Exception - if exceptions occur while starting.
      • writeTrackingFile

        public void writeTrackingFile()
                               throws java.lang.Exception
        Writes pertinent configuration information to tracking file
        Throws:
        java.lang.Exception - if error occurs
      • readTrackingFile

        public javax.json.JsonObject readTrackingFile()
                                               throws java.lang.Exception
        Reads contents of tracking file
        Returns:
        JsonObject containing tracking file contents, or null if file doesn't exist
        Throws:
        java.lang.Exception - if error occurs
      • onMessage

        public void onMessage​(io.nats.streaming.Message message)
        Defines behavior for message receipt. Attempts to process notifications, with configurable behavior for exception handling
        Specified by:
        onMessage in interface io.nats.streaming.MessageHandler
        Parameters:
        message - The message received from the STAN server
      • getTrackingFileName

        public java.lang.String getTrackingFileName()
        Returns:
        trackingFileName
      • setTrackingFileName

        public void setTrackingFileName​(java.lang.String trackingFileName)
        Parameters:
        trackingFileName - to set
      • getClient

        public NATSClient getClient()
        Returns:
        NATSClient
      • setClient

        public void setClient​(NATSClient client)
        Parameters:
        client - NATSClient to set
      • getSubject

        public java.lang.String getSubject()
        Returns:
        subject
      • setSubject

        public void setSubject​(java.lang.String subject)
        Parameters:
        subject - to set