2 #include "orbsvcs/CosEventChannelAdminS.h"
3 #include "ace/OS_NS_unistd.h"
4 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT ("file://ec.ior");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
14 while ((c
= get_opts ()) != -1)
18 ior
= get_opts
.opt_arg ();
23 ACE_ERROR_RETURN ((LM_ERROR
,
30 // Indicates successful parsing of the command line
35 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
39 return supplier
.run (argc
, argv
);
42 // ****************************************************************
49 Supplier::run (int argc
, ACE_TCHAR
* argv
[])
53 // ORB initialization boiler plate...
55 CORBA::ORB_init (argc
, argv
);
57 if (parse_args (argc
, argv
) != 0)
60 CORBA::Object_var object
=
61 orb
->resolve_initial_references ("RootPOA");
62 PortableServer::POA_var poa
=
63 PortableServer::POA::_narrow (object
.in ());
64 PortableServer::POAManager_var poa_manager
=
65 poa
->the_POAManager ();
66 poa_manager
->activate ();
68 // Obtain the event channel, we could use a naming service, a
69 // command line argument or resolve_initial_references(), but
72 orb
->string_to_object (ior
);
74 CosEventChannelAdmin::EventChannel_var event_channel
=
75 CosEventChannelAdmin::EventChannel::_narrow (object
.in ());
77 // The canonical protocol to connect to the EC
78 CosEventChannelAdmin::SupplierAdmin_var supplier_admin
=
79 event_channel
->for_suppliers ();
81 CosEventChannelAdmin::ProxyPushConsumer_var consumer
=
82 supplier_admin
->obtain_push_consumer ();
84 CosEventComm::PushSupplier_var supplier
=
87 consumer
->connect_push_supplier (supplier
.in ());
90 ACE_Time_Value
sleep_time (0, 10000); // 10 milliseconds
93 event
<<= CORBA::ULong (10);
95 for (int i
= 0; i
!= 2000; ++i
)
97 consumer
->push (event
);
98 ACE_OS::sleep (sleep_time
);
101 // Disconnect from the EC
102 consumer
->disconnect_push_consumer ();
104 // Destroy the EC....
105 event_channel
->destroy ();
107 // Deactivate this object...
108 PortableServer::ObjectId_var id
=
109 poa
->servant_to_id (this);
110 poa
->deactivate_object (id
.in ());
115 catch (const CORBA::Exception
& ex
)
117 ex
._tao_print_exception ("Supplier::run");
124 Supplier::disconnect_push_supplier ()