// work_queue work items is are automatically dequeued and called by proton
 // This function is called because it was queued by send()
 void do_send(const proton::message& m) {
     sender_.send(m);
     std::lock_guard<std::mutex> l(lock_);
     --queued_;                    // work item was consumed from the work_queue
     credit_ = sender_.credit();   // update credit
     sender_ready_.notify_all();       // Notify senders we have space on queue
 }
Example #2
0
    void send_request() {
        proton::message req;
        req.body(requests.front());
        req.reply_to(receiver.remote_source().address());

        sender.send(req);
    }
Example #3
0
 // Only called if we have credit. Return true if we sent a message.
 bool do_send(queue* q, proton::sender &s) {
     proton::message m;
     bool popped =  q->pop(m, has_messages_callback_);
     if (popped)
         s.send(m);
     /// if !popped the queue has saved the callback for later.
     return popped;
 }
Example #4
0
 void on_sendable(proton::sender &sender) override {
     while (sender.credit() && sent_ < total_) {
         id_value_ = sent_ + 1;
         message_.correlation_id(id_value_);
         message_.creation_time(proton::timestamp::now());
         sender.send(message_);
         sent_++;
     }
 }
Example #5
0
 void send_available_messages(proton::sender &s) {
     for (int i = sequence; available && s.credit() > 0; i++) {
         std::ostringstream mbody;
         mbody << "flow_sender message " << sequence++;
         proton::message m(mbody.str());
         s.send(m);
         available--;
     }
 }
Example #6
0
 void on_sendable(proton::event &e, proton::sender &sender) override {
     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++;
     }
 }
Example #7
0
 void on_sendable(proton::event &e, proton::sender &s) override {
     proton::message m;
     m.body("Hello World!");
     s.send(m);
     s.close();
 }