Interstage Application Server アプリケーション作成ガイド (イベントサービス編)
目次 索引 前ページ次ページ

第4章 アプリケーションの開発(各機能)> 4.1 イベントチャネル接続のアプリケーション開発> 4.1.1 ノーティフィケーションサービスのQoS機能の運用

4.1.1.1 QoSプロパティ項目の設定

 QoSプロパテ項目は、イベントチャネル(静的生成、動的生成)およびメッセージに設定できます。

(1)イベントチャネルに対するQoSプロパティ項目の設定方法

 静的生成イベントチャネルのQoSプロパティ項目の設定は、CosNotification::QoSAdmin::set_qos()を使って、QoSPropertiesを設定します。動的生成イベントチャネルのQoSプロパティ項目の設定は、CosNotifyChannelAdmin::EventChannelFactory::create_channel()を使ってイベントチャネルの生成時に、QoSPropertiesを設定します。QoSPropertiesはProperty構造体からなるシーケンス型です。C++プログラムでQoSPropertiesを作成し、イベントチャネルに対してQoSプロパティ項目を設定する例と処理の流れを以下に説明します。

[QoSPropertiesの作成例(C++の場合)]

    CORBA::Short     priority        = 0;                                /* 1 */
    CORBA::ULongLong timeout         = 40;                               /* 2 */
    CORBA::Short     orderpolicy     = CosNotification::PriorityOrder;   /* 3 */
    CORBA::Short     discardpolicy   = CosNotification::AnyOrder;        /* 4 */

    CosNotification::Property_var    *pProperty =
            CosNotification::PropertySeq::allocbuf( 4 );                 /* 5 */

    pProperty[0]->name  = CORBA::string_dup( CosNotification::Priority ); 
    pProperty[0]->value = new CORBA::Any(); 
    *(pProperty[0]->value) <<= priority;                                 /* 6 */

    pProperty[1]->name  = CORBA::string_dup( CosNotification::Timeout ); 
    pProperty[1]->value = new CORBA::Any(); 
    *(pProperty[1]->value) <<= timeout;                                  /* 7 */

    pProperty[2]->name  = CORBA::string_dup( CosNotification::OrderPolicy ); 
    pProperty[2]->value = new CORBA::Any(); 
    *(pProperty[2]->value) <<= orderpolicy;                              /* 8 */

    pProperty[3]->name  = CORBA::string_dup( CosNotification::DiscardPolicy ); 
    pProperty[3]->value = new CORBA::Any(); 
    *(pProperty[3]->value) <<= discardpolicy;                            /* 9 */

    CosNotification::QoSProperties *pQoS =
                        new CosNotification::QoSProperties(
                            4, 4, pProperty, CORBA_TRUE );               /* 10 */

    try{
        ... 
        channel = イベントチャネルのオブジェクトリファレンスの獲得
        channel->set_qos( *pQoS, env );                                  /* 11 */
        ... 
    } catch( CORBA::Exception &e ) {
        ... 
    }

    /* 動的生成イベントチャネルの生成時 */
    try{
        ... 
        channel=factory->create_channel(*pQoS,*pAdmin,channelID, env );  /* 12 */
        ... 
    } catch( CORBA::Exception &e ) {
        ... 
    }
  1. Priorityの値を設定します(short型)。
  2. Timeoutの値を設定します(unsigned long long型)。
  3. OrderPolicyの値を設定します(short型)。
  4. DiscardPolicyの値を設定します(short型)。
  5. 上記4項目分のバッファ領域を獲得します。
  6. nameにPriority、valueにany型で1の値を設定します。
  7. nameにTimeout、valueにany型で2の値を設定します。
  8. nameにOrderPolicy、valueにany型で3の値を設定します。
  9. nameにDiscardPolicy、valueにany型で4の値を設定します。
  10. 6〜9までのシーケンス型であるQoSPropertiesを作成します。
  11. イベントチャネルに対してQoSプロパティ項目を設定します。
    動的生成イベントチャネルの場合は、12のイベントチャネルの生成時にも指定できます。
  12. 動的生成イベントチャネルの場合は、イベントチャネルの生成時にQoSプロパティ項目を設定します。

(2)メッセージに対するQoSプロパティ項目の設定方法

 メッセージにQoSプロパティ項目を設定するには、StructuredEvent型データの中のOptionalHeaderFieldsとして設定します。OptionalHeaderFieldsはProperty構造体からなるシーケンス型です。C++プログラムでQoSプロパティ項目を設定したStructuredEvent型データの作成例と処理の流れを以下に説明します。

[StructuredEvent型データの作成例(C++の場合)]

    CORBA::Short     priority      = 0;                                  /* 1 */
    CORBA::ULongLong timeout       = 40;                                 /* 2 */

    CosNotification::StructuredEvent  *se =                              /* 3 */
               new CosNotification::StructuredEvent(); 

    CosNotification::Property_var     *pProperty =
            CosNotification::PropertySeq::allocbuf( 2 );                 /* 4 */

    pProperty[0]->name  = CORBA::string_dup( CosNotification::Priority ); 
    pProperty[0]->value = new CORBA::Any(); 
    *(pProperty[0]->value) <<= priority;                                 /* 5 */

    pProperty[1]->name  = CORBA::string_dup( CosNotification::Timeout ); 
    pProperty[1]->value = new CORBA::Any(); 
    *(pProperty[1]->value) <<= timeout;                                  /* 6 */

    CosNotification::OptionalHeaderFields *variable_header_data =
                        new CosNotification::OptionalHeaderFields(
                            2, 2, pProperty, CORBA_TRUE );               /* 7 */

    CosNotification::FilterableEventBody *filterable_data_data =
                        new CosNotification::FilterableEventBody(
                            0, 0, NULL, CORBA_FALSE );                   /* 8 */

    /* ---- domain_name ---- */
    se->header->fixed_header->event_type->domain_name =
                              CORBA::string_dup( "Telecom" );            /* 9 */
    
    /* ---- type_name ---- */
    se->header->fixed_header->event_type->type_name =
                              CORBA::string_dup( "CommunicationsAlarm" ); 
                                                                         /* 10 */
    /* ---- event_name ---- */
    se->header->fixed_header->event_name =
                              CORBA::string_dup( "data" );               /* 11 */

    /* ---- remainder_of_data->_value ---- */
    CORBA::Char* string_data; 
    string_data = CORBA::string_dup( "StructuredEvent data" ); 
    CORBA::Any *Any_data = new CORBA::Any(
            _tc_string, string_data, CORBA_TRUE );                       /* 12 */

    se->header->variable_header = variable_header_data; 
    se->filterable_data         = filterable_data_data; 
    se->remainder_of_body       = Any_data;
  1. Priorityの値を設定します(short型)。
  2. Timeoutの値を設定します(unsigned long long型)。
  3. StructuredEvent型データを作成します。
  4. 1、2の項目分のバッファ領域を獲得します。
  5. nameにPriority、valueにany型で1の値を設定します。
  6. nameにTimeout、valueにany型で2の値を設定します。
  7. 5〜6までのシーケンス型であるOptionalHeaderFieldsを作成します。
  8. FilterableEventBodyには作成例のように設定してください。
  9. domain_nameを設定します。
  10. type_nameを設定します。
  11. event_nameを設定します。
  12. remainder_of_bodyを作成します。ここで送信したいデータ本体を設定します。
    例では"StructuredEvent data"というstring型のデータを作成しています。

目次 索引 前ページ次ページ

All Rights Reserved, Copyright(C) 富士通株式会社 2005