Before you can send or receive messages using QAnywhere C++ clients, you must complete the following initialization tasks.
To initialize the QAnywhere C++ API
Include the QAnywhere header file.
#include <qa.hpp> |
qa.hpp defines the QAnywhere classes.
Initialize QAnywhere.
To do this, initialize a factory for creating QAManager objects.
QAManagerFactory * factory; factory = QAnywhereFactory_init(); if( factory == NULL ) { // Fatal error. } |
For more information about QAManagerFactory, see QAManagerFactory class.
Create a QAManager instance.
You can create a default QAManager object as follows:
QAManager * mgr; // Create a manager mgr = factory->createQAManager( NULL ); if( mgr == NULL ) { // fatal error } |
See QAManager class.
For maximum concurrency benefits, multi-threaded applications should create a QAManager for each thread. See Multi-threading considerations.
You can customize a QAManager object programmatically or using a properties file.
See Setting QAnywhere manager configuration properties programmatically.
mgr = factory->createQAManager( "qa_mgr.props" ); |
where qa_mgr.props is the name of the properties file on the remote device.
See Setting QAnywhere manager configuration properties in a file.
Initialize the QAManager object.
qa_bool rc; rc=mgr->open( AcknowledgementMode::IMPLICIT_ACKNOWLEDGEMENT ); |
The argument to the open method is an acknowledgement mode, which indicates how messages are to be acknowledged. It must be one of IMPLICIT_ACKNOWLEDGEMENT or EXPLICIT_ACKNOWLEDGEMENT. With implicit acknowledgement, messages are acknowledged as soon as they are received by the client. With explicit acknowledgement, you must call one of the acknowledge methods on the QAManager to acknowledge the message.
For more information about acknowledgement modes, see AcknowledgementMode class.
Instead of creating a QAManager, you can create a QATransactionalManager. See Implementing transactional messaging for C++ clients.
You are now ready to send messages.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |