示例#1
0
    def _processIncoming(self, delivery, connector):
        link = proton.pn_delivery_link(delivery)
        ssn = proton.pn_link_session(link)
        msg = []
        self.log.debug("Receiving '%s'", proton.pn_delivery_tag(delivery))
        while True:
            rc, buff = proton.pn_link_recv(link, 1024)
            msg.append(buff)
            if rc == proton.PN_EOS:
                break

        msg = ''.join(msg)

        self.log.debug("Received '%s'", proton.pn_delivery_tag(delivery))
        proton.pn_link_advance(link)
        proton.pn_delivery_update(delivery, proton.PN_ACCEPTED)
        proton.pn_delivery_settle(delivery)

        msgObj = proton.Message()
        msgObj.decode(msg)
        ctx = proton.pn_session_get_context(ssn)
        ctx._pushIncomingMessage(msgObj.body)

        # if more credit is needed, grant it
        if proton.pn_link_credit(link) == 0:
            proton.pn_link_flow(link, MBUFF_SIZE)
示例#2
0
    def _processIncoming(self, delivery, connector):
        link = proton.pn_delivery_link(delivery)
        ssn = proton.pn_link_session(link)
        msg = []
        self.log.debug("Receiving '%s'", proton.pn_delivery_tag(delivery))
        while True:
            rc, buff = proton.pn_link_recv(link, 1024)
            msg.append(buff)
            if rc == proton.PN_EOS:
                break

        msg = ''.join(msg)

        self.log.debug("Received '%s'", proton.pn_delivery_tag(delivery))
        proton.pn_link_advance(link)
        proton.pn_delivery_update(delivery, proton.PN_ACCEPTED)
        proton.pn_delivery_settle(delivery)

        msgObj = proton.Message()
        msgObj.decode(msg)
        ctx = proton.pn_session_get_context(ssn)
        ctx._pushIncomingMessage(msgObj.body)

        # if more credit is needed, grant it
        if proton.pn_link_credit(link) == 0:
            proton.pn_link_flow(link, MBUFF_SIZE)
示例#3
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)
示例#4
0
 def _processOutgoing(self, delivery):
     link = proton.pn_delivery_link(delivery)
     msg = proton.pn_delivery_get_context(delivery)
     proton.pn_link_send(link, msg)
     if proton.pn_link_advance(link):
         self.log.debug("Delivery finished (%s)",
                        proton.pn_delivery_tag(delivery))
         proton.pn_delivery_set_context(delivery, time.time())
示例#5
0
 def _processOutgoing(self, delivery):
     link = proton.pn_delivery_link(delivery)
     msg = proton.pn_delivery_get_context(delivery)
     proton.pn_link_send(link, msg)
     if proton.pn_link_advance(link):
         self.log.debug("Delivery finished (%s)",
                        proton.pn_delivery_tag(delivery))
         proton.pn_delivery_set_context(delivery, time.time())
示例#6
0
    def _processIncoming(self, delivery, connector):
        link = proton.pn_delivery_link(delivery)
        ssn = proton.pn_link_session(link)
        msg = []
        rc, buff = proton.pn_link_recv(link, 1024)
        while rc >= 0:
            msg.append(buff)
            rc, buff = proton.pn_link_recv(link, 1024)

        msg = ''.join(msg)

        proton.pn_delivery_update(delivery, proton.PN_ACCEPTED)
        msgObj = proton.Message()
        msgObj.decode(msg)
        ctx = proton.pn_session_get_context(ssn)
        ctx._pushIncomingMessage(msgObj.body)

        proton.pn_delivery_settle(delivery)
        proton.pn_link_advance(link)

        # if more credit is needed, grant it
        if proton.pn_link_credit(link) == 0:
            proton.pn_link_flow(link, 1)