Initialize QAnywhere.
This step is the same as in non-transactional messaging.
import ianywhere.qanywhere.client.*; QAManagerFactory fact = QAManagerFactory.getInstance(); |
Create a QATransactionalManager object.
For example, to create a default QATransactionalManager object, invoke createQATransactionalManager with null as its parameter:
QATransactionalManager mgr = fact.createQATransactionalManager(); // no argument |
You can alternatively create a QATransactionalManager object that is customized using a properties file. The properties file is specified in the createQATransactionalManager method:
mgr = factory.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.
Initialize 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(); msg_2 = mgr.createTextMessage(); mgr.putMessage( "jms_1\\queue_name", msg_1 ); mgr.putMessage( "jms_1\\queue_name", msg_2 ); 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.
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |