Create a transactional managerInitialize QAnywhere.
This step is the same as in non-transactional messaging.
#include <qa.hpp>
QAManagerFactory * factory;
factory = QAnywhereFactory_init();
if( factory == NULL ) {
// Fatal error.
} |
Create a transactional manager.
QATransactionalManager * mgr;
mgr = factory->createQATransactionalManager( NULL );
if( mgr == NULL ) {
// Fatal error.
} |
As with non-transactional managers, you can specify a properties file to customize QAnywhere behavior. In this example, no properties file is used.
Initialize the manager.
if( !mgr->open() ) {
// Display message using mgr->getLastErrorMsg().
} |
You are now ready to send messages. The following procedure sends two messages in a single transaction.
Send multiple messages in a single transactionInitialize message objects.
QATextMessage * msg_1; QATextMessage * msg_2; |
Send the messages.
The following code sends two messages in a single transaction:
msg_1 = mgr->createTextMessage();
if( msg_1 != NULL ) {
msg_2 = mgr->createTextMessage();
if( msg_2 != NULL ) {
if( !mgr->putMessage( "jms_1\\queue_name", msg_1 ) ) {
// Display message using mgr->getLastErrorMsg().
} else {
if( !mgr->putMessage( "jms_1\\queue_name", msg_2 ) ) {
// Display message using mgr->getLastErrorMsg().
} else {
mgr->commit();
}
}
mgr->deleteMessage( msg_2 );
}
mgr->deleteMessage( msg_1 );
} |
The commit method commits the current transaction and begins a new transaction. This method commits all putMessage() method and getMessage() method invocations.
The first transaction begins with the call to open method.
See also![]() |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |