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; CORBA_unsigned_long_long *timeout; CORBA_short *orderpolicy; CORBA_short *discardpolicy; CosNotification_Property *pProperty; CosNotification_QoSProperties *pQoS=NULL; priority = CORBA_short_alloc(); *priority = 1; /* 1 */ timeout = CORBA_unsigned_long_long_alloc(); *timeout = 40; /* 2 */ orderpolicy = CORBA_short_alloc(); *orderpolicy = CosNotification_PriorityOrder; /* 3 */ discardpolicy = CORBA_short_alloc(); *discardpolicy = CosNotification_AnyOrder; /* 4 */ pProperty = CosNotification_PropertySeq_allocbuf( 4 ); /* 5 */ pProperty[0].name = CORBA_string_alloc( strlen( CosNotification_Priority ) ); strcpy( pProperty[0].name, CosNotification_Priority ); pProperty[0].value._type = TC_short; pProperty[0].value._value = priority; /* 6 */ pProperty[1].name = CORBA_string_alloc( strlen( CosNotification_Timeout ) ); strcpy( pProperty[1].name, CosNotification_Timeout ); pProperty[1].value._type = TC_ulonglong; pProperty[1].value._value = timeout; /* 7 */ pProperty[2].name = CORBA_string_alloc( strlen( CosNotification_OrderPolicy ) ); strcpy( pProperty[2].name, CosNotification_OrderPolicy ); pProperty[2].value._type = TC_short; pProperty[2].value._value = orderpolicy; /* 8 */ pProperty[3].name = CORBA_string_alloc( strlen( CosNotification_DiscardPolicy ) ); strcpy( pProperty[3].name, CosNotification_DiscardPolicy ); pProperty[3].value._type = TC_short; pProperty[3].value._value = discardpolicy; /* 9 */ pQoS = CosNotification_QoSProperties_alloc(); /* 10 */ pQoS->_length = 4; pQoS->_maximum = 4; pQoS->_buffer = pProperty; ... channel = イベントチャネルのオブジェクトリファレンスの獲得 CosNotifyChannelAdmin_EventChannel_set_qos( channel, pQoS, &env ); /* 11 */ ... /* 動的生成イベントチャネルの生成時 */ CosNotifyChannelAdmin_EventChannelFactory_create_channel( factory, pQoS, pAdmin, channelID, &env ); /* 12 */ ... }
メッセージにQoSプロパティ項目を設定するには、StructuredEvent型データの中のOptionalHeaderFieldsとして設定します。OptionalHeaderFieldsはProperty構造体からなるシーケンス型です。CプログラムでQoSプロパティ項目を設定したStructuredEvent型データの作成例と処理の流れを以下に説明します。
[StructuredEvent型データの作成例(Cの場合)]
CORBA_short *priority; CORBA_unsigned_long_long *timeout; CosNotification_Property *pProperty; CosNotification_StructuredEvent *event; CORBA_char *domain_name_data; CORBA_char *type_name_data; CORBA_char *event_name_data; CORBA_string *any_string; priority = CORBA_short_alloc(); *priority = 1; /* 1 */ timeout = CORBA_unsigned_long_long_alloc(); *timeout = 40; /* 2 */ event = CosNotification_StructuredEvent_alloc(); /* 3 */ pProperty = CosNotification_PropertySeq_allocbuf( 2 ); /* 4 */ pProperty[0].name = CORBA_string_alloc( strlen( CosNotification_Priority ) ); strcpy( pProperty[0].name, CosNotification_Priority ); pProperty[0].value._type = TC_short; pProperty[0].value._value = priority; /* 5 */ pProperty[1].name = CORBA_string_alloc( strlen( CosNotification_Timeout ) ); strcpy( pProperty[1].name, CosNotification_Timeout ); pProperty[1].value._type = TC_ulonglong; pProperty[1].value._value = timeout; /* 6 */ /* ---- domain_name ---- */ domain_name_data = CORBA_string_alloc( strlen( "Telecom" ) ); strcpy( domain_name_data, "Telecom" ); event->header.fixed_header.event_type.domain_name = domain_name_data; /* 7 */ /* ---- type_name ---- */ type_name_data = CORBA_string_alloc( strlen( "CommunicationsAlarm" ) ); strcpy( type_name_data, "CommunicationsAlarm" ); event->header.fixed_header.event_type.type_name = type_name_data; /* 8 */ /* ---- event_name ---- */ event_name_data = CORBA_string_alloc( strlen( "data" ) ); strcpy( event_name_data, "data" ); event->header.fixed_header.event_name = event_name_data; /* 9 */ /* ---- remainder_of_data->_value ---- */ event->filterable_data._maximum = 0; event->filterable_data._length = 0; event->filterable_data._buffer = NULL; any_string = CORBA_string_ptr_alloc(); *any_string = CORBA_string_alloc( strlen("StructuredEvent data"); strcpy( *any_string, "StructuredEvent data" ); event->remainder_of_body._type = TC_string; event->remainder_of_body._value = any_string; /* 10 */
目次
索引
![]() ![]() |