Publisher Stop Function Processing

Publishers process stop messages received from the Operators Console using the appropriate callback functions and flag checking.

You enable start and stop functioning by configuration settings in the agent-plugin.xml file.

When an operator presses Stop on the Operations Console, the agent sends a stop message to the publisher's administration port so that the publisher can handle the termination request.

When the publisher receives the stop message:
  • The publisher code defines a callback function. This function, called when a user selects the stop button of the publisher, sets a shutdown flag. For example, the shutdown flag in the demo feed handler is:
    void publisherShutdown(){
        feedhandler.setShutDown(true);
        std::cout << "A shutdown process is requested" << std::endl;
    }
    
  • The startup structure is passed to the publisher API through the publisher initialization call. When the publisher API receives the stop message through the administration port, it calls the callback function. For example, the callback function for the demo feed handler is:
    startup.callbacks.shutdown = publisherShutdown;
    
  • In the publisher's loop of sending messages, the code occasionally checks the shutdown flag. When the flag is set to true, the code breaks out of the loop, performs cleanup, and ends the process. For example, the shutdown flag in the demo feed handler is:
    if (feedhandler.isShutDown()){
        
        throw "Shutdown has been requested.";
    }