1 // ******************************************************************
3 // ******************************************************************
5 #include "ace/OS_NS_unistd.h"
6 #include "Notify_Structured_Push_Consumer.h"
7 #include "Notify_Test_Client.h"
8 #include "orbsvcs/Notify/Notify_Extensions.h"
11 // ******************************************************************
13 // ******************************************************************
15 Notify_Structured_Push_Consumer::Notify_Structured_Push_Consumer (
17 unsigned int expected
,
18 Notify_Test_Client
& client
)
26 this->client_
.consumer_start (this);
30 Notify_Structured_Push_Consumer::set_delay_parameters (unsigned int delay_count
, unsigned long delay_period
)
32 this->delay_count_
= delay_count
;
33 this->delay_period_
= delay_period
;
37 Notify_Structured_Push_Consumer::_connect (
38 CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin
)
40 #ifdef TEST_QOS_MAX_EVENTS_PER_CONSUMER
41 CosNotification::QoSProperties
properties (8);
42 properties
.length (2);
44 properties
[idx
].name
= CORBA::string_dup (CosNotification::DiscardPolicy
);
45 properties
[idx
].value
<<= this->CosNotification::FifoOrder
;
47 properties
[idx
].name
= CORBA::string_dup (CosNotification::MaxEventsPerConsumer
);
48 properties
[idx
].value
<<= 500;
50 ACE_OS::printf("Setting %d::%d QoS properties in Admin.\n", (int)idx
, (int)properties
.length());
51 consumer_admin
->set_qos (properties
);
52 #endif // TEST_QOS_MAX_EVENTS_PER_CONSUMER
54 CosNotifyComm::StructuredPushConsumer_var objref
= this->_this ();
56 CosNotifyChannelAdmin::ProxySupplier_var proxysupplier
=
57 consumer_admin
->obtain_notification_push_supplier (
58 CosNotifyChannelAdmin::STRUCTURED_EVENT
,
62 CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow (
65 this->proxy_
->connect_structured_push_consumer (objref
.in ());
67 CosNotification::EventTypeSeq
added (1);
68 CosNotification::EventTypeSeq
removed (1);
72 added
[0].domain_name
= CORBA::string_dup ("*");
73 added
[0].type_name
= CORBA::string_dup ("examples");
75 removed
[0].domain_name
= CORBA::string_dup ("*");
76 removed
[0].type_name
= CORBA::string_dup ("*");
78 this->subscription_change (added
, removed
);
80 // give ownership to POA
86 Notify_Structured_Push_Consumer::push_structured_event (
87 const CosNotification::StructuredEvent
&)
89 ACE_DEBUG ((LM_DEBUG
, "-"));
90 static const ACE_Time_Value
sl (0, 2000);
94 if (this->delay_count_
!= 0 && this->count_
% this->delay_count_
== 0)
96 ACE_OS::sleep (this->delay_period_
);
99 if (this->count_
> this->expected_
)
101 ACE_ERROR ((LM_ERROR
,
102 ACE_TEXT ("Structured Consumer (%P|%t): ERROR: too ")
103 ACE_TEXT ("many events received.\n")));
106 if (this->count_
>= this->expected_
)
108 ACE_DEBUG ((LM_DEBUG
, "\nConsumer received %u events.\n", count_
));
109 this->client_
.consumer_done (this);