 To create a transactional manager
 To create a transactional managerInitialize QAnywhere.
This step is the same as in non-transactional messaging.
| using iAnywhere.QAnywhere.Client; | 
Create a QATransactionalManager object.
For example, to create a default QATransactionalManager object, invoke CreateQATransactionalManager with null as its parameter:
| QAManager mgr; mgr = QAManagerFactory.Instance.CreateQATransactionalManager( null ); | 
You can alternatively create a QATransactionalManager object that is customized using a properties file. The properties file is specified in the CreateQATransactionalManager method:
| mgr = QAManagerFactory.Instance.CreateQATransactionalManager( "qa_mgr.props" ); | 
where qa_mgr.props is the name of the properties file that resides on the remote device.
Initialize the QAManager object.
| mgr.Open(); | 
You are now ready to send messages. The following procedure sends two messages in a single transaction.
 To send multiple messages in a single transaction
 To 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();
      }
    }
  }
} | 
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
 See also|  | Discuss this page in DocCommentXchange.
                   | Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |