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

5.4 Mixedモデル

C言語でのMixedモデルのアプリケーションの開発について説明します。


(1)概要

Mixedモデルは、Pushモデル、Pullモデルの2つの通信モデルを使用します。サプライヤはイベントチャネルにイベントデータを送信し、コンシューマはイベントチャネルにイベントデータを要求します。
本概要を以下の図に示します。



(2)サプライヤの作成

サプライヤは、イベントチャネルにイベントデータを送信します。Pushモデルのサプライヤと同様のインタフェースを使用します。
サプライヤからコンシューマにイベントデータを送信する処理の手続きの例、および処理の流れを以下に示します。


イベントサービスの場合

[C言語によるMixedモデルのサプライヤ]

CORBA_Boolean func() {
    ... 
    supplier = CosEventChannelAdmin_EventChannel_for_suppliers(
                                     object, &env );                      /* 1 */
    proxy_push = CosEventChannelAdmin_SupplierAdmin_obtain_push_consumer(
                                     supplier, &env );                    /* 2 */
    CosEventChannelAdmin_ProxyPushConsumer_connect_push_supplier(
                                     proxy_push, CORBA_OBJECT_NIL, &env); /* 3 */
    CosEventChannelAdmin_ProxyPushConsumer_push(
                                     proxy_push, data, &env );            /* 4 */
    CosEventChannelAdmin_ProxyPushConsumer_disconnect_push_consumer(
                                     proxy_push, &env );                  /* 5 */
    ... 
}

ノーティフィケーションサービスの場合

[C言語によるMixedモデル(StructuredEvent型)のサプライヤ]

CORBA_Boolean func() {
    ...
    supplier = CosNotifyChannelAdmin_EventChannel_get_default_supplier_admin (
                                     object, &env );                      /* 1 */
    proxy_push =
          CosNotifyChannelAdmin_SupplierAdmin_obtain_notification_push_consumer (
                                     supplier,ctype,&proxy_id, &env);     /* 2 */
    CosNotifyChannelAdmin_StructuredProxyPushConsumer_connect_structured_push_supplier(
                                     proxy_push, CORBA_OBJECT_NIL, &env); /* 3 */
    CosNotifyChannelAdmin_StructuredProxyPushConsumer_push_structured_event (
                                     proxy_push, data, &env );            /* 4 */
    CosNotifyChannelAdmin_StructuredProxyPushConsumer_disconnect_structured_push_consumer (
                                     proxy_push, &env );                  /* 5 */
    ... 
}

[C言語によるMixedモデル(any型)のサプライヤ]

CORBA_Boolean func() {
    ...
    supplier = CosNotifyChannelAdmin_EventChannel_get_default_supplier_admin (
                                     object, &env );                      /* 1 */
    proxy_push =
          CosNotifyChannelAdmin_SupplierAdmin_obtain_notification_push_consumer (
                                     supplier,ctype,&proxy_id, &env);     /* 2 */
    CosNotifyChannelAdmin_ProxyPushConsumer_connect_any_push_supplier(
                                     proxy_push, CORBA_OBJECT_NIL, &env); /* 3 */
    CosNotifyChannelAdmin_ProxyPushConsumer_push(
                                     proxy_push, data, &env );            /* 4 */
    CosNotifyChannelAdmin_ProxyPushConsumer_disconnect_push_consumer (
                                     proxy_push, &env );                  /* 5 */
    ... 
}

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

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

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

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

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


(3)コンシューマの作成

コンシューマは、イベントチャネルにイベントデータを要求します。Pullモデルのコンシューマと同様のインタフェースを使用します。
コンシューマがイベントチャネルにイベントデータを要求する手続きの例、および処理の流れを以下に示します。


イベントサービスの場合

[C言語によるMixedモデルのコンシューマ]

CORBA_Boolean func() {
    ... 
    consumer = CosEventChannelAdmin_EventChannel_for_consumers(
                                    object, &env );                      /* 1 */
    proxy_pull = CosEventChannelAdmin_ConsumerAdmin_obtain_pull_supplier(
                                    consumer, &env );                    /* 2 */
    CosEventChannelAdmin_ProxyPullSupplier_connect_pull_consumer(
                                    proxy_pull, CORBA_OBJECT_NIL, &env); /* 3 */
    data = CosEventChannelAdmin_ProxyPullSupplier_pull(
                                    proxy_pull, &env );                  /* 4 */
    CosEventChannelAdmin_ProxyPullSupplier_disconnect_pull_supplier(
                                    proxy_pull, &env );                  /* 5 */
    ... 
}

ノーティフィケーションサービスの場合

[C言語によるMixedモデル(StructuredEvent型)のコンシューマ]

CORBA_Boolean func() {
    ... 
    consumer = CosNotifyChannelAdmin_EventChannel_get_default_consumer_admin(
                               object, &env );                               /* 1 */
    proxy_pull =
          CosNotifyChannelAdmin_ConsumerAdmin_obtain_notification_pull_supplier(
                               consumer,ctype,&proxyID,&env );               /* 2 */
    CosNotifyChannelAdmin_StructuredProxyPullSupplier_connect_structured_pull_consumer(
                                proxy_pull, CORBA_OBJECT_NIL,&proxyID,&env); /* 3 */
    data = CosNotifyChannelAdmin_StructuredProxyPullSupplier_pull_structured_event (
                                proxy_pull, &env );                          /* 4 */
    CosNotifyChannelAdmin_StructuredProxyPullSupplier_disconnect_structured_pull_
                                supplier (proxy_pull, &env );                /* 5 */
    ... 
}

[C言語によるMixedモデル(any型)のコンシューマ]

CORBA_Boolean func() {
    ... 
    consumer = CosNotifyChannelAdmin_EventChannel_get_default_consumer_admin(
                               object, &env );                              /* 1 */
    proxy_pull =
          CosNotifyChannelAdmin_ConsumerAdmin_obtain_notification_pull_supplier(
                               consumer,ctype,&proxyID,&env );              /* 2 */
    CosNotifyChannelAdmin_ProxyPullSupplier_connect_any_pull_consumer(
                               proxy_pull, CORBA_OBJECT_NIL,&proxyID,&env); /* 3 */
    data = CosNotifyChannelAdmin_ProxyPullSupplier_pull(
                               proxy_pull, &env );                          /* 4 */
    CosNotifyChannelAdmin_ProxyPullSupplier_disconnect_pull_supplier(
                               proxy_pull, &env );                          /* 5 */
    ... 
}

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

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

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

  4. イベントチャネルからイベントデータを受信します。

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


注意

pullメソッド/pull_waitメソッドを発行してイベントデータを待ち合わせている状態で、disconnectメソッドを発行してイベントチャネルと切断しないように注意してください。イベントデータを待ち合わせている場合は、pull_cancellメソッドを発行してイベントデータの待合せを解除させてからdisconnectメソッドを発行してください。

pullメソッド/pull_waitメソッドを発行してイベントデータを待ち合わせている状態で、disconnectメソッドを発行すると、トレースファイルに以下のメッセージが多量に出力されて、I/Oエラーが発生する可能性があります。

Exception information : method = pull()、pull_structured_event()、またはpull_wait()
 exception = COMM_FAILURE minor = 0x464a01c2 group =(グループ名), channel = (イベントチャネル名),
 ClientIP = (アプリケーションのIPアドレス) pid = (プロセスID) internalcode = (内部コード)