1 #include "Notify_Sequence_Push_Consumer.h"
4 #include "Notify_Test_Client.h"
6 #include "orbsvcs/CosNotifyCommC.h"
7 #include "orbsvcs/CosNamingC.h"
9 #include "ace/Get_Opt.h"
10 #include "ace/OS_NS_unistd.h"
11 #include "ace/OS_NS_sys_stat.h"
13 static const ACE_TCHAR
*ior
= ACE_TEXT ("file://supplier.ior");
14 static CORBA::Short order_policy
= CosNotification::FifoOrder
;
15 static int expected
= 30; // Must match the amount sent by supplier
16 static Notify_Sequence_Push_Consumer
* consumer_1
;
17 static bool use_ordering
= false;
19 class Consumer_Client
: public Notify_Test_Client
22 virtual int parse_args (int argc
, ACE_TCHAR
*argv
[]);
27 Consumer_Client::parse_args (int argc
, ACE_TCHAR
*argv
[])
29 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("ok:e:d:"));
32 while ((c
= get_opts ()) != -1)
36 ior
= get_opts
.optarg
;
40 expected
= ACE_OS::atoi (get_opts
.optarg
);
49 const ACE_TCHAR
*order
= get_opts
.optarg
;
50 if (ACE_OS::strcmp (order
, ACE_TEXT ("fifo")) == 0)
52 order_policy
= CosNotification::FifoOrder
;
54 else if (ACE_OS::strcmp (order
, ACE_TEXT ("priority")) == 0)
56 order_policy
= CosNotification::PriorityOrder
;
58 else if (ACE_OS::strcmp (order
, ACE_TEXT ("deadline")) == 0)
60 order_policy
= CosNotification::DeadlineOrder
;
61 #if !defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
62 ACE_ERROR_RETURN ((LM_ERROR
,
63 "This order policy requires timed message "
64 "blocks.\nPlease #define "
65 "ACE_HAS_TIMED_MESSAGE_BLOCKS in your "
71 ACE_ERROR_RETURN ((LM_ERROR
,
72 "Unknown ordering policy: %s\n",
79 ACE_ERROR_RETURN ((LM_ERROR
,
82 "-e <expected events> "
83 "-d <fifo|priority|deadline> "
88 // Indicates successful parsing of the command line
93 static CosNotifyChannelAdmin::ConsumerAdmin_ptr
94 create_consumeradmin (CosNotifyChannelAdmin::EventChannel_ptr ec
)
96 CosNotifyChannelAdmin::AdminID adminid
= 0;
97 CosNotifyChannelAdmin::ConsumerAdmin_var admin
=
98 ec
->new_for_consumers (CosNotifyChannelAdmin::OR_OP
,
102 return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (admin
.in ());
107 create_consumers (CosNotifyChannelAdmin::ConsumerAdmin_ptr admin
,
108 Notify_Test_Client
* client
)
110 ACE_NEW_THROW_EX (consumer_1
,
111 Notify_Sequence_Push_Consumer ("consumer1",
116 CORBA::NO_MEMORY ());
118 consumer_1
->init (client
->root_poa ());
120 consumer_1
->_connect (admin
);
123 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
127 Consumer_Client client
;
129 int status
= client
.init (argc
, argv
);
130 ACE_UNUSED_ARG(status
);
131 ACE_ASSERT(status
== 0);
133 CosNotifyChannelAdmin::EventChannel_var ec
=
134 client
.create_event_channel ("MyEventChannel", 1);
136 CORBA::ORB_ptr orb
= client
.orb ();
137 CORBA::Object_var object
=
138 orb
->string_to_object (ior
);
140 sig_var sig
= sig::_narrow (object
.in ());
142 ACE_ASSERT(! CORBA::is_nil (sig
.in ()));
144 CosNotifyChannelAdmin::ConsumerAdmin_var admin
=
145 create_consumeradmin (ec
.in ());
147 ACE_ASSERT(!CORBA::is_nil (admin
.in ()));
148 create_consumers (admin
.in (), &client
);
154 ACE_DEBUG((LM_DEBUG
, "Consumer done.\n"));
155 consumer_1
->disconnect();
161 catch (const CORBA::Exception
& e
)
163 e
._tao_print_exception ("Error: ");