예제 #1
0
 void on_accepted(proton::event &e) {
     confirmed_++;
     e.delivery().settle();
     if (confirmed_ == total_) {
         std::cout << "all messages confirmed" << std::endl;
         if (!replying_)
             e.connection().close();
     }
 }
예제 #2
0
 void on_message(proton::event &e) {
     if (requests.empty()) return; // Spurious extra message!
     proton::message& response = e.message();
     std::cout << requests.front() << " => " << response.body() << std::endl;
     requests.erase(requests.begin());
     if (!requests.empty()) {
         send_request();
     } else {
         e.connection().close();
     }
 }
예제 #3
0
 void on_message(proton::event &e) {
     std::cout << "Received " << e.message().body() << std::endl;
     std::string reply_to = e.message().reply_to();
     proton::message reply;
     reply.address(reply_to);
     reply.body(to_upper(e.message().body().get<std::string>()));
     reply.correlation_id(e.message().correlation_id());
     if (!senders[reply_to])
         senders[reply_to] = e.connection().open_sender(reply_to);
     senders[reply_to].send(reply);
 }
예제 #4
0
 void on_message(proton::event &e) {
     proton::message &msg = e.message();
     msg.body().decode() >> received_content_;
     received_bytes_ += received_content_.size();
     if (received_ < total_) {
         received_++;
     }
     e.delivery().settle();
     if (received_ == total_) {
         e.receiver().close();
         e.connection().close();
     }
 }
 void on_connection_open(proton::event &e) {
     std::cout << "Inbound server connection connected via SSL.  Protocol: " <<
         e.connection().transport().ssl().protocol() << std::endl;
     if (e.connection().transport().sasl().outcome() == sasl::OK) {
         std::string subject = e.connection().transport().ssl().remote_subject();
         std::cout << "Inbound client certificate identity " << find_CN(subject) << std::endl;
     }
     else {
         std::cout << "Inbound client authentication failed" <<std::endl;
         e.connection().close();
     }
     inbound_listener.close();
 }
예제 #6
0
 void on_message(proton::event &e) {
     proton::message& msg = e.message();
     if (msg.id().get<uint64_t>() < received)
         return; // ignore duplicate
     if (expected == 0 || received < expected) {
         std::cout << msg.body() << std::endl;
         received++;
     }
     if (received == expected) {
         e.receiver().close();
         e.connection().close();
         if (!!acceptor) acceptor.close();
     }
 }
예제 #7
0
파일: broker.cpp 프로젝트: Karm/qpid-proton
 void on_link_opening(proton::event &e) {
     proton::link& lnk = e.link();
     if (lnk.is_sender()) {
         proton::sender &sender(lnk.sender());
         proton::terminus &remote_source(lnk.remote_source());
         if (remote_source.is_dynamic()) {
             std::string address = queue_name();
             lnk.source().address(address);
             queue *q = new queue(true);
             queues[address] = q;
             q->subscribe(sender);
             std::cout << "broker dynamic outgoing link from " << address << std::endl;
         }
         else {
             std::string address = remote_source.address();
             if (!address.empty()) {
                 lnk.source().address(address);
                 get_queue(address).subscribe(sender);
                 std::cout << "broker outgoing link from " << address << std::endl;
             }
         }
     }
     else {
         std::string address = lnk.remote_target().address();
         if (!address.empty())
             lnk.target().address(address);
         std::cout << "broker incoming link to " << address << std::endl;
     }
 }
예제 #8
0
    void on_sendable(proton::event &e) {
        proton::link lnk = e.link();
        std::string address = lnk.local_source().address();
        proton::sender s = lnk.sender();

        queues_.get(address).dispatch(&s);
    }
예제 #9
0
    void on_link_close(proton::event &e) {
        proton::link lnk = e.link();

        if (!!lnk.sender()) {
            unsubscribe(lnk.sender());
        }
    }
예제 #10
0
 void on_delivery_accept(proton::event &e) {
     confirmed++;
     if (confirmed == total) {
         std::cout << "all messages confirmed" << std::endl;
         e.connection().close();
         acceptor.close();
     }
 }
예제 #11
0
    void 
    on_message ( proton::event &e ) 
    {
      log ( "on_message" );

      double receive_timestamp = get_timestamp();

      proton::message& msg = e.message();

      double send_timestamp = msg.body().get<double>();
      double latency = receive_timestamp - send_timestamp;

      fprintf ( output_fp, "latency %.6lf\n", latency );

      if ( ! received )
      {
        rr_init ( & resource_reporter );
      }

      if ( (expected == 0)
           || 
           (expected == -1)
           || 
           (received < expected)
         ) 
      {
        received++;
        if ( ! ( received % report_frequency ) )
        {
          report ( output_fp );
        }

        if (received == expected) 
        {
          log ( "closing receiver and connection." );
          e.receiver().close();
          e.connection().close();
          char filename[1000];
          sprintf ( filename, "/tmp/simple_recv_%d_is_done", getpid() );
          FILE * fp = fopen ( filename, "w" );
          fprintf ( fp, ":-)\n" );
          fclose ( fp );
        }
      }
    }
예제 #12
0
 void on_sendable(proton::event &e) {
     proton::sender sender = e.sender();
     while (sender.credit() && sent < total) {
         proton::message msg;
         msg.id(sent + 1);
         std::map<std::string, int> m;
         m["sequence"] = sent+1;
         msg.body(m);
         sender.send(msg);
         sent++;
     }
 }
예제 #13
0
    void on_sendable(proton::event &e) {
        proton::sender sender = e.sender();

        while (sender.credit() && sent_ < total_) {
            id_value_ = sent_ + 1;
            message_.correlation_id(id_value_);
            proton::amqp_timestamp reactor_now(reactor_.now());
            message_.creation_time(reactor_now);
            sender.send(message_);
            sent_++;
        }
    }
    void on_start(proton::event &e) {
        // Configure listener.  Details vary by platform.
        ssl_certificate server_cert = platform_certificate("tserver", "tserverpw");
        std::string client_CA = platform_CA("tclient");
        // Specify an SSL domain with CA's for client certificate verification.
        server_domain sdomain(server_cert, client_CA);
        connection_options server_opts;
        server_opts.server_domain(sdomain).handler(&s_handler);
        server_opts.allowed_mechs("EXTERNAL");
        e.container().server_connection_options(server_opts);

        // Configure client.
        ssl_certificate client_cert = platform_certificate("tclient", "tclientpw");
        std::string server_CA = platform_CA("tserver");
        client_domain cdomain(client_cert, server_CA);
        connection_options client_opts;
        client_opts.client_domain(cdomain).allowed_mechs("EXTERNAL");
        // Validate the server certificate against this name:
        client_opts.peer_hostname("test_server");
        e.container().client_connection_options(client_opts);

        s_handler.inbound_listener = e.container().listen(url);
        e.container().open_sender(url);
    }
예제 #15
0
    void on_link_open(proton::event &e) {
        proton::link lnk = e.link();

        if (!!lnk.sender()) {
            proton::terminus remote_source(lnk.remote_source());
            queue &q = remote_source.dynamic() ?
                queues_.dynamic() : queues_.get(remote_source.address());
            lnk.local_source().address(q.name());

            q.subscribe(lnk.sender());
            std::cout << "broker outgoing link from " << q.name() << std::endl;
        } else {
            // Receiver
            std::string address = lnk.remote_target().address();
            if (!address.empty()) {
                lnk.local_target().address(address);
                std::cout << "broker incoming link to " << address << std::endl;
            }
        }
    }
예제 #16
0
 void on_start(proton::event &e) {
     acceptor = e.container().listen(url);
     std::cout << "direct_recv listening on " << url << std::endl;
 }
예제 #17
0
 void on_start(proton::event &e) {
     e.connection().open();
     e.connection().open_receiver(address_);
     e.connection().open_sender(address_);
 }
예제 #18
0
 void on_message(proton::event &e) {
     std::cout << e.message().body() << std::endl;
     e.connection().close();
 }
예제 #19
0
 void on_start(proton::event &e) {
     e.container().open_sender(url_);
     reactor_ = e.container().reactor();
 }
예제 #20
0
 void
 on_unhandled ( proton::event &e )
 {
   log ( "on_unhandled |%s| ", e.name().c_str() );
 }
예제 #21
0
 void on_message(proton::event &e) {
     std::cout << e.message().body() << std::endl;
 }
예제 #22
0
 void 
 on_start(proton::event &e) 
 {
   log ( "on_start listening on |%s|", url.str().c_str() );
   receiver = e.container().open_receiver(url);
 }
예제 #23
0
 void on_sendable(proton::event &e) {
     proton::message m;
     m.body("Hello World!");
     e.sender().send(m);
     e.sender().close();
 }
예제 #24
0
 void on_start(proton::event &e) {
     sender = e.container().open_sender(url);
 }
예제 #25
0
    void on_start(proton::event &e) {
        connection = e.container().connect(url);
        connection.open_receiver(url.path());

        std::cout << "server connected to " << url << std::endl;
    }
예제 #26
0
 void on_message(proton::event &e) {
     std::string address = e.link().local_target().address();
     
     queues_.get(address).publish(e.message(), e.link().receiver());
 }
예제 #27
0
 void on_transport_close(proton::event &e) {
     remove_stale_consumers(e.connection());
 }
예제 #28
0
 void on_accepted(proton::event &e) {
     e.connection().close();
 }
예제 #29
0
 void on_start(proton::event &e) {
     e.container().listen(url_);
     std::cout << "broker listening on " << url_ << std::endl;
 }
예제 #30
0
 void on_start(proton::event &e) {
     acceptor = e.container().listen(url).ptr();
     e.container().create_sender(url);
 }