Beispiel #1
0
    def _queueOutgoingDeliveries(self, conn):
        ctxs = (ctx for ctx in self._sessionContexts
                if ctx.connection == conn)

        for ctx in ctxs:
            sender = ctx.sender

            if sender is None:
                # No sender link
                sender = proton.pn_sender(ctx.session,
                                          "sender-%s" % str(uuid.uuid4()))
                ctx.sender = sender
                proton.pn_link_open(sender)
                continue

            if proton.pn_link_credit(sender) == 0:
                self.log.debug("Not enough credit, waiting")
                continue

            try:
                data = ctx._popPendingMessage()
            except Empty:
                continue
            else:
                msg = proton.Message()
                msg.body = data
                self.log.debug("Creating delivery")
                proton.pn_link_set_context(sender, msg.encode())

                proton.pn_delivery(sender,
                                   "response-delivery-%s" % str(uuid.uuid4()))
Beispiel #2
0
 def _processOutgoing(self, delivery):
     link = proton.pn_delivery_link(delivery)
     msg = proton.pn_link_get_context(link)
     sent = proton.pn_link_send(link, msg)
     if sent < 0:
         self.log.warn("Problem sending message")
     else:
         msg = msg[sent:]
         if len(msg) != 0:
             self.log.debug("Delivery partial")
             proton.pn_link_set_context(link, msg)
         else:
             self.log.debug("Delivery finished")
             proton.pn_link_set_context(link, "")
             proton.pn_delivery_set_context(delivery, time.time())
             proton.pn_link_advance(link)