예제 #1
0
void
Notify_Sequence_Push_Consumer::_connect (
  CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin)
{
  CosNotifyComm::SequencePushConsumer_var objref =
    this->_this ();

  CosNotifyChannelAdmin::ProxySupplier_var proxysupplier =
    consumer_admin->obtain_notification_push_supplier (
    CosNotifyChannelAdmin::SEQUENCE_EVENT,
    proxy_id_);

  this->proxy_ =
    CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow (
    proxysupplier.in ());

  CosNotification::QoSProperties properties (1);
  properties.length (1);
  properties[0].name = CORBA::string_dup (CosNotification::PacingInterval);
  properties[0].value <<= PACING;

  this->proxy_->set_qos (properties);
  this->proxy_->connect_sequence_push_consumer (objref.in ());

  // give ownership to POA
  this->_remove_ref ();
}
void
Notify_Sequence_Push_Consumer::_connect (
  CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin)
{
  CosNotifyComm::SequencePushConsumer_var objref =
    this->_this ();

  CosNotifyChannelAdmin::ProxySupplier_var proxysupplier =
    consumer_admin->obtain_notification_push_supplier (
    CosNotifyChannelAdmin::SEQUENCE_EVENT,
    proxy_id_);

  this->proxy_ =
    CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow (
    proxysupplier.in ());

  CosNotification::QoSProperties properties (3);
  properties.length (3);
  properties[0].name = CORBA::string_dup (CosNotification::MaximumBatchSize);
  properties[0].value <<= (CORBA::Long) BATCH_SIZE;
  properties[1].name = CORBA::string_dup (CosNotification::PacingInterval);
  properties[1].value <<= (TimeBase::TimeT) (1000 * 10000); // 1 secs
  if (use_ordering_)
  {
    properties[2].name = CORBA::string_dup (CosNotification::OrderPolicy);
    properties[2].value <<= this->order_policy_;
  }
  else
  {
    properties.length(2);
  }

  this->proxy_->set_qos (properties);
  this->proxy_->connect_sequence_push_consumer (objref.in ());

  // give ownership to POA
  this->_remove_ref ();
}
void
Notify_Sequence_Push_Consumer::_connect (
    CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin)
{
    CosNotifyComm::SequencePushConsumer_var consumer =
        this->_this ();

    CosNotifyChannelAdmin::ProxySupplier_var proxysupplier =
        consumer_admin->obtain_notification_push_supplier (
            CosNotifyChannelAdmin::SEQUENCE_EVENT,
            proxy_id_);

    this->proxy_ =
        CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow (
            proxysupplier.in ());

    CosNotification::QoSProperties properties (4);
    properties.length (4);
    CORBA::ULong idx = 0;
    properties[idx].name = CORBA::string_dup (CosNotification::MaximumBatchSize);
    properties[idx].value <<= BATCH_SIZE;
    properties[++idx].name = CORBA::string_dup (CosNotification::PacingInterval);
    properties[idx].value <<= PACING;
    properties[++idx].name = CORBA::string_dup (CosNotification::DiscardPolicy);
    properties[idx].value <<= this->discard_policy_;
    properties[++idx].name = CORBA::string_dup (CosNotification::MaxEventsPerConsumer);
    // We set this equal to the batch size so that we conveniently always receive
    // one more batch after the first.
    properties[idx].value <<= BATCH_SIZE;

    this->proxy_->set_qos (properties);
    this->proxy_->connect_sequence_push_consumer (consumer.in ());

    // give ownership to POA
    this->_remove_ref ();
}
예제 #4
0
void
TAO_Notify_SequenceProxyPushSupplier::load_attrs (const TAO_Notify::NVPList& attrs)
{
  SuperClass::load_attrs(attrs);
  ACE_CString ior;
  if (attrs.load("PeerIOR", ior))
  {
    CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb();
    try
    {
      CosNotifyComm::SequencePushConsumer_var pc = CosNotifyComm::SequencePushConsumer::_nil();
      if (ior.length() > 0)
      {
        CORBA::Object_var obj = orb->string_to_object(ior.c_str());
        pc = CosNotifyComm::SequencePushConsumer::_unchecked_narrow(obj.in());
      }
      this->connect_sequence_push_consumer(pc.in());
    }
    catch (const CORBA::Exception&)
    {
      // if we can't reconnect, tough
    }
  }
}
예제 #5
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
  {
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    CORBA::Object_var obj = orb->resolve_initial_references("NameService");

    CosNaming::NamingContextExt_var naming_context =
      CosNaming::NamingContextExt::_narrow(obj.in());

    obj = naming_context->resolve_str("MyEventChannel");
    CosNotifyChannelAdmin::EventChannel_var ec =
      CosNotifyChannelAdmin::EventChannel::_narrow(obj.in());

    CosNotifyChannelAdmin::AdminID adminid;
    CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
      CosNotifyChannelAdmin::AND_OP;

    CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
      ec->new_for_consumers(ifgop,
      adminid);

    obj = orb->resolve_initial_references("RootPOA");

    PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in());

    PortableServer::Servant_var<EventSequenceConsumer_i> servant =
      new EventSequenceConsumer_i(orb.in());

    PortableServer::ObjectId_var objectId = poa->activate_object(servant.in());

    obj = poa->id_to_reference (objectId.in());
    CosNotifyComm::SequencePushConsumer_var consumer =
      CosNotifyComm::SequencePushConsumer::_narrow(obj.in());

    CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;

    CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
      consumer_admin->obtain_notification_push_supplier(
      CosNotifyChannelAdmin::SEQUENCE_EVENT,
          consumeradmin_proxy_id);

    CosNotifyChannelAdmin::SequenceProxyPushSupplier_var supplier_proxy =
      CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow(proxy_supplier.in());

    supplier_proxy->connect_sequence_push_consumer(consumer.in());

    CosNotification::EventTypeSeq added (1);
    CosNotification::EventTypeSeq removed (1);
    added.length (1);
    removed.length (1);

    added[0].domain_name = CORBA::string_dup ("OCI_TAO");
    added[0].type_name = CORBA::string_dup ("examples");

    removed[0].domain_name = CORBA::string_dup ("*");
    removed[0].type_name = CORBA::string_dup ("*");

    supplier_proxy->subscription_change(added, removed);

    PortableServer::POAManager_var poa_manager = poa->the_POAManager();

    poa_manager->activate();

    orb->run();

    orb->destroy();

    return 0;
  }
  catch(const CORBA::Exception& ex)
  {
    std::cerr << "Caught exception: " << ex << std::endl;
  }
  return 1;
}