2 #include "orbsvcs/CosNotifyChannelAdminC.h"
3 //#include <orbsvcs/CosNotifyCommS.h>
4 //#include <orbsvcs/CosNotificationS.h>
5 #include "tao/TimeBaseC.h"
8 #include "ace/OS_NS_stdio.h"
10 using namespace CORBA
;
11 namespace CNCA
= CosNotifyChannelAdmin
;
12 namespace CN
= CosNotification
;
13 namespace CNC
= CosNotifyComm
;
15 const char* NOTIFY_IOR
= "corbaloc::localhost:9050/NotifyEventChannelFactory";
18 CNCA::EventChannelFactory_var ecf
;
21 void init_qos_props(CN::QoSProperties
& qos
, bool topology_persist
) {
24 qos
[i
].name
= "EventReliability";
25 qos
[i
++].value
<<= CN::BestEffort
;
26 if (topology_persist
) {
27 qos
[i
].name
= "ConnectionReliability";
28 qos
[i
++].value
<<= CN::Persistent
;
32 qos
[i
].name
= "ConnectionReliability";
33 qos
[i
++].value
<<= CN::BestEffort
;
35 qos
[i
].name
= "Priority";
36 qos
[i
++].value
<<= (Short
) 1234;
37 qos
[i
].name
= "Timeout";
38 qos
[i
++].value
<<= (TimeBase::TimeT
) 55555; // 5.5555 ms
39 qos
[i
].name
= "MaximumBatchSize";
40 qos
[i
++].value
<<= (Long
) 200;
41 qos
[i
].name
= "PacingInterval";
42 qos
[i
++].value
<<= (TimeBase::TimeT
) 42000; // 4.2ms
43 qos
[i
].name
= "StopTimeSupported";
44 qos
[i
++].value
<<= Any::from_boolean(0);
47 void init_admin_props(CN::AdminProperties
& admin
) {
50 admin
[i
].name
= "MaxQueueLength";
51 admin
[i
++].value
<<= (Long
) 200;
52 admin
[i
].name
= "MaxConsumers";
53 admin
[i
++].value
<<= (Long
) 2;
54 admin
[i
].name
= "MaxSuppliers";
55 admin
[i
++].value
<<= (Long
) 1;
56 admin
[i
].name
= "RejectNewEvents";
57 admin
[i
++].value
<<= Any::from_boolean(1);
63 orb
= ORB_init(ac
, av
.argv());
64 ACE_ASSERT(! is_nil(orb
.in()));
65 Object_var obj
= orb
->string_to_object(NOTIFY_IOR
);
66 ACE_ASSERT(! is_nil(obj
.in()));
67 ecf
= CNCA::EventChannelFactory::_narrow(obj
.in());
68 ACE_ASSERT(! is_nil(ecf
.in()));
73 ecf
= CNCA::EventChannelFactory::_nil();
80 int ACE_TMAIN (int, ACE_TCHAR
*[])
86 CN::QoSProperties qos
;
87 CN::AdminProperties admin
;
88 init_qos_props(qos
, true);
89 init_admin_props(admin
);
92 CNCA::EventChannel_var ec
= ecf
->create_channel(qos
, admin
, ecid
);
94 ACE_OS::printf("Created channel id=\"%ld\"\n", static_cast<long>(ecid
));
102 ACE_OS::fputs(e
._name (), stderr
);
103 ACE_OS::fputs("\n", stderr
);