为了同步接收消息,应用程序显式轮询队列检查是否有消息。可以定期或当用户启动某个特定的操作(例如,单击 [刷新] 按钮)时轮询队列。
同步接收消息 (C++)
声明消息对象以保存进来的消息。
QAMessage * msg; QATextMessage * text_msg;
轮询消息队列,接收消息:
if( mgr->start() ) {
for( ;; ) {
msg = mgr->getMessageNoWait( "queue_name" );
if( msg == NULL ) break;
text_msg = msg->castToTextMessage();
if( text_msg != NULL ) {
// display text message using
// text_msg->getText()
}
sleep( time-period );
}
mgr->stop();
}同步接收消息 (.NET)
声明消息对象以保存进来的消息。
QAMessage msg; QATextMessage text_msg;
轮询消息队列,收集消息:
if(mgr.start() ) {
for(;;) {
msg = mgr.GetMessageNoWait("queue_name");
if( msg == null ) break;
addMessage( msg );
}
mgr.stop();
}SQL Anywhere Studio 9.0.2
版权所有 © 1989–2005 Sybase, Inc. 部分版权所有 © 2001–2005 iAnywhere Solutions, Inc. 保留所有权利。