Interstage Application Server アプリケーション作成ガイド (イベントサービス編) |
目次
索引
![]() ![]() |
第4章 アプリケーションの開発(各機能) | > 4.1 イベントチャネル接続のアプリケーション開発 | > 4.1.1 ノーティフィケーションサービスのQoS機能の運用 |
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 ) { ... }
メッセージに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;
目次
索引
![]() ![]() |