ページの先頭行へ戻る
Interstage Application Server アプリケーション作成ガイド(イベントサービス編)

6.7 ローカルトランザクション

[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 ) {
          ... 
    }
    ... 
}

  1. ChannelUtilインタフェースのオブジェクトリファレンスを獲得します。

  2. イベントチャネル管理オブジェクトのオブジェクトリファレンスを獲得します。

  3. イベントチャネルのオブジェクトリファレンスを獲得します。

  4. イベントチャネルと接続します。

  5. ローカルトランザクションを開始します。

  6. イベントチャネルにイベントデータを送信します。

  7. ローカルトランザクションを完了します。

  8. イベントチャネルと切断します。


  接続するイベントチャネルのオブジェクトリファレンスを不揮発媒体に保存している場合、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 ) {
          ... 
    }
    ... 
}

  1. ChannelUtilインタフェースのオブジェクトリファレンスを獲得します。

  2. イベントチャネル管理オブジェクトのオブジェクトリファレンスを獲得します。

  3. イベントチャネルのオブジェクトリファレンスを獲得します。

  4. イベントチャネルと接続します。

  5. ローカルトランザクションを開始します。

  6. イベントチャネルにイベントデータを受信します。

  7. ローカルトランザクションを完了します。

  8. イベントチャネルと切断します。


  接続するイベントチャネルのオブジェクトリファレンスを不揮発媒体に保存している場合、2, 3, 4, 8の処理は不要となります。