REQUIREMENT client.cpp.failsafe |
Type | NEW |
Priority | HIGH |
Status | CLOSED |
Topic | The c++ client library supports failsafe reconnect where published messages are queued as long as the communication to xmlBlaster is broken. | ||||||||||||||||
Des cription |
Hidden inside ConnectionsHandler there is a mechanism which in asynchronous way pings xmlBlaster
to check if the communication is ok. When the ping fails, or when a request to xmlBlaster fails due
to communication problems, the client library tries to reestablish the connection. This is done
in an asynchronous way (an own thread in ConnectionHandler). While the library tries to
reconnect all publish requests are queued on ram or persistently depending on the For a detailed explication of the feature have a look at the specific requirement for failsafe reconnect. You can register a listener to be instantly notified about the connection status changes. To do so the following methods must be implemented by the object implementing the I_ConnectionProblems interface. It is the object passed in the initFailsafe(...) method in XmlBlasterAccess.
The reachedAlive method returns a bool. If you return true the queue will be flushed, i.e. the queue entries will be dispatched to xmlBlaster. If you return false, all queue entries will be discarded. If you don't invoke the method initFailsafe or if you pass to it a NULL pointer, then the failsafe mode and the described failsafe behavior runs silently in the client library. Note also that you must invoke initFailsafe before you invoke connect.
NOTE: To activate the failsafe mode you need to pass the command line parameter
|
||||||||||||||||
Example CPP |
class HelloWorld2 : public I_Callback, public I_ConnectionProblems { ...... bool reachedAlive(StatesEnum, I_ConnectionsHandler*) { log_.info(ME, "reconnected"); return true; } void reachedDead(StatesEnum, I_ConnectionsHandler*) { log_.info(ME, "lost connection"); } void reachedPolling(StatesEnum, I_ConnectionsHandler*) { log_.info(ME, "going to poll modus"); } ...... void execute() { try { XmlBlasterAccess con(global_); // here you initialize the failsafe behaviour by giving // a pointer to the instance to notify when a state change // occcurs (which in this case is the 'this' object) con.initFailsafe(this); // do what you want to do here (connect publish subscribe) ..... } string update(const string& sessionId, UpdateKey& updateKey, void *content, long contentSize, UpdateQos& updateQos) { log_.info(ME, "update: key: " + updateKey.toXml()); log_.info(ME, "update: qos: " + updateQos.toXml()); return ""; } }; |
||||||||||||||||
Configure |
These parameters allow to configure the C++-client on command line, over xmlBlaster.properties or over the environment (with lower priority):
NOTE: Configuration parameters are specified on command line (-someValue 17) or in the
xmlBlaster.properties file (someValue=17). See requirement "util.property" for details. |
||||||||||||||||
See REQ | client.cpp | ||||||||||||||||
See REQ | client.cpp.queue | ||||||||||||||||
See REQ | client.failsafe |
This page is generated from the requirement XML file xmlBlaster/doc/requirements/client.cpp.failsafe.xml