1 #include "orbsvcs/CosNamingC.h"
2 #include "orbsvcs/FtRtecEventChannelAdminC.h"
3 #include "orbsvcs/Event_Utilities.h"
4 #include "PushConsumer.h"
5 #include "ace/Get_Opt.h"
6 #include "orbsvcs/FtRtEvent/Utils/resolve_init.h"
7 #include "orbsvcs/FtRtEvent/Utils/FTEC_Gateway.h"
9 /// include this file to statically linked with FT ORB
10 #include "orbsvcs/FaultTolerance/FT_ClientService_Activate.h"
12 /// include this file to statically linked with Transaction Depth
13 #include "orbsvcs/FtRtEvent/ClientORB/FTRT_ClientORB_Loader.h"
17 std::unique_ptr
<TAO_FTRTEC::FTEC_Gateway
> gateway
;
19 RtecEventChannelAdmin::EventChannel_ptr
20 get_event_channel(int argc
, ACE_TCHAR
** argv
)
22 FtRtecEventChannelAdmin::EventChannel_var channel
;
23 ACE_Get_Opt
get_opt (argc
, argv
, ACE_TEXT("hi:n"));
27 while ((opt
= get_opt ()) != EOF
)
33 CORBA::Object_var obj
= orb
->string_to_object(get_opt
.opt_arg ());
34 channel
= FtRtecEventChannelAdmin::EventChannel::_narrow(obj
.in());
43 ACE_TEXT("Usage: %s ")
44 ACE_TEXT("-i ftrt_eventchannel_ior\n")
45 ACE_TEXT("-n do not use gateway\n")
52 if (CORBA::is_nil(channel
.in()))
54 CosNaming::Name
name(1);
56 name
[0].id
= CORBA::string_dup("FT_EventService");
58 CosNaming::NamingContext_var naming_context
=
59 resolve_init
<CosNaming::NamingContext
>(orb
.in(), "NameService");
61 channel
= resolve
<FtRtecEventChannelAdmin::EventChannel
>(naming_context
.in(),
67 gateway
.reset (new TAO_FTRTEC::FTEC_Gateway(orb
.in(), channel
.in()));
68 return gateway
->_this();
71 return channel
._retn();
74 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
77 orb
= CORBA::ORB_init (argc
, argv
);
79 RtecEventChannelAdmin::EventChannel_var channel
80 = get_event_channel (argc
, argv
);
83 if (CORBA::is_nil(channel
.in()))
84 ACE_ERROR_RETURN ((LM_ERROR
, "Cannot Find FT_EventService\n"), -1);
86 PortableServer::POA_var poa
=
87 resolve_init
<PortableServer::POA
>(orb
.in(), "RootPOA");
89 PortableServer::POAManager_var mgr
= poa
->the_POAManager();
93 PushConsumer_impl
push_consumer_impl(orb
.in());
94 RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin
=
95 channel
->for_consumers();
97 RtecEventChannelAdmin::ProxyPushSupplier_var supplier
=
98 consumer_admin
->obtain_push_supplier();
100 RtecEventChannelAdmin::ConsumerQOS qos
;
102 qos
.dependencies
.length(1);
104 RtecEventComm::EventHeader
& h0
=
105 qos
.dependencies
[0].event
.header
;
106 h0
.type
= ACE_ES_EVENT_UNDEFINED
; // first free event type
107 h0
.source
= ACE_ES_EVENT_SOURCE_ANY
;
109 RtecEventComm::PushConsumer_var push_consumer
=
110 push_consumer_impl
._this();
112 supplier
->connect_push_consumer(push_consumer
.in(),
117 catch (const CORBA::Exception
& ex
){
118 ex
._tao_print_exception ("A CORBA Exception occurred.");