初始化 QAnywhere。
这一步骤与在非事务性消息传递中的步骤相同。
using iAnywhere.QAnywhere.Client; |
创建 QATransactionalManager 对象。
例如,要创建缺省的 QATransactionalManager 对象,可调用 CreateQATransactionalManager:
QATransactionalManager mgr = fact.CreateQATransactionalManager(); // no argument |
也可以创建使用属性文件自定义的 QATransactionalManager 对象。属性文件在 CreateQATransactionalManager 方法中指定:
QAManagerFactory fact = QAManagerFactory.Instance( "qa_mgr.props" ); |
其中,qa_mgr.props 是远程设备上属性文件的名称。
初始化 QAManager 对象。
mgr.Open(); |
现在,即可发送消息。以下过程在一个事务中发送两条消息。
初始化消息对象。
QATextMessage msg_1; QATextMessage msg_2; |
发送消息。
以下代码在一个事务中发送两条消息:
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(); |
Commit 方法可提交当前事务并开始一个新事务。此方法提交全部 PutMessage() 方法和 GetMessage() 方法调用。
第一个事务以对 open 方法的调用开始。
![]() |
使用DocCommentXchange讨论此页。
|
版权 © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |