C++言語でのローカルトランザクションのアプリケーションの開発について説明します。
[C++言語によるMixedモデルのローカルトランザクションのサプライヤ]
CORBA::Boolean func() {
...
try {
tmp_util= EventCh->create_util(
CosEventChannelAdmin::EventChannel::CHANNEL_UTIL, env ); /* 1 */
util = ES::ChannelUtil::_narrow( tmp_util );
supplier = EventCh->default_supplier_admin( env ); /* 2 */
tmp_proxy = supplier->obtain_notification_push_consumer(
ctype,proxy_id, env ); /* 3 */
proxy_push = CosNotifyChannelAdmin::
StructuredProxyPushConsumer::_narrow( tmp_proxy );
proxy_push->connect_structured_push_supplier(
CosNotifyComm::StructuredPushSupplier::_nil(),env); /* 4 */
util->local_begin( proxy_push , env ); /* 5 */
proxy_push->push_structured_event(data,env); /* 6 */
util->local_commit ( proxy_push , env ); /* 7 */
proxy_push->disconnect_structured_push_consumer(env); /* 8 */
} catch( CORBA::Exception &e ) {
...
}
...
}ChannelUtilインタフェースのオブジェクトリファレンスを獲得します。
イベントチャネル管理オブジェクトのオブジェクトリファレンスを獲得します。
イベントチャネルのオブジェクトリファレンスを獲得します。
イベントチャネルと接続します。
ローカルトランザクションを開始します。
イベントチャネルにイベントデータを送信します。
ローカルトランザクションを完了します。
イベントチャネルと切断します。
接続するイベントチャネルのオブジェクトリファレンスを不揮発媒体に保存している場合、2, 3, 4, 8の処理は不要となります。
[C++言語によるMixedモデルのローカルトランザクションのコンシューマ]
CORBA::Boolean func() {
...
try {
tmp_util= EventCh->create_util(
CosEventChannelAdmin::EventChannel::CHANNEL_UTIL, env ); /* 1 */
util = ES::ChannelUtil::_narrow( tmp_util );
consumer = EventCh->default_consumer_admin( env ); /* 2 */
tmp_proxy = consumer->obtain_notification_pull_supplier(
ctype,proxy_id,env); /* 3 */
proxy_pull = CosNotifyChannelAdmin::StructuredProxyPullSupplier::_narrow(
tmp_proxy );
proxy_pull->connect_structured_pull_consumer(
CosNotifyComm::StructuredPullConsumer::_nil(),env); /* 4 */
util->local_begin( proxy_pull , env ); /* 5 */
data = proxy_pull->pull_structured_event(env); /* 6 */
util->local_commit ( proxy_pull , env ); /* 7 */
proxy_pull->disconnect_structured_pull_supplier(env); /* 8 */
} catch( CORBA::Exception &e ) {
...
}
...
}ChannelUtilインタフェースのオブジェクトリファレンスを獲得します。
イベントチャネル管理オブジェクトのオブジェクトリファレンスを獲得します。
イベントチャネルのオブジェクトリファレンスを獲得します。
イベントチャネルと接続します。
ローカルトランザクションを開始します。
イベントチャネルにイベントデータを受信します。
ローカルトランザクションを完了します。
イベントチャネルと切断します。
接続するイベントチャネルのオブジェクトリファレンスを不揮発媒体に保存している場合、2, 3, 4, 8の処理は不要となります。