Ejemplo n.º 1
0
    def _cleanDeliveries(self, conn):
        link = proton.pn_link_head(conn, (proton.PN_LOCAL_ACTIVE))
        while link:
            d = proton.pn_unsettled_head(link)
            while d:
                _next = proton.pn_unsettled_next(d)
                disp = proton.pn_delivery_remote_state(d)
                age = time.time() - proton.pn_delivery_get_context(d)
                self.log.debug("Checking delivery")
                if disp and disp != proton.PN_ACCEPTED:
                    self.log.warn("Message was not accepted by remote end")

                if disp and proton.pn_delivery_settled(d):
                    self.log.debug("Message settled by remote end")
                    proton.pn_delivery_settle(d)

                elif age > self._deliveryTimeout:
                    self.log.warn("Delivary not settled by remote host")
                    proton.pn_delivery_settle(d)

                elif proton.pn_link_state(link) & proton.PN_REMOTE_CLOSED:
                    self.log.warn("Link closed before settling message")
                    proton.pn_delivery_settle(d)

                d = _next

            link = proton.pn_link_next(link, (proton.PN_LOCAL_ACTIVE))
Ejemplo n.º 2
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())
Ejemplo n.º 3
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())
Ejemplo n.º 4
0
    def _cleanDeliveries(self, conn):
        def link_iter(conn):
            link = proton.pn_link_head(conn, (proton.PN_LOCAL_ACTIVE))
            while link:
                yield link
                link = proton.pn_link_next(link, (proton.PN_LOCAL_ACTIVE))

        def delivery_iter(link):
            d = proton.pn_unsettled_head(link)
            while d:
                yield d
                d = proton.pn_unsettled_next(d)

        for link in link_iter(conn):
            for d in delivery_iter(link):
                ctx = proton.pn_delivery_get_context(d)
                if isinstance(ctx, str):
                    continue

                disp = proton.pn_delivery_remote_state(d)
                age = time.time() - ctx
                self.log.debug("Checking delivery (%s)",
                               proton.pn_delivery_tag(d))

                if disp and disp != proton.PN_ACCEPTED:
                    self.log.warn("Message was not accepted by remote end")

                if disp and proton.pn_delivery_settled(d):
                    self.log.debug("Message settled by remote end")
                    proton.pn_delivery_settle(d)
                    proton.pn_delivery_clear(d)

                elif age > self._deliveryTimeout:
                    self.log.warn("Delivary not settled by remote host")
                    proton.pn_delivery_settle(d)
                    proton.pn_delivery_clear(d)

                elif proton.pn_link_state(link) & proton.PN_REMOTE_CLOSED:
                    self.log.warn("Link closed before settling message")
                    proton.pn_delivery_settle(d)
                    proton.pn_delivery_clear(d)
Ejemplo n.º 5
0
    def _cleanDeliveries(self, conn):
        def link_iter(conn):
            link = proton.pn_link_head(conn, (proton.PN_LOCAL_ACTIVE))
            while link:
                yield link
                link = proton.pn_link_next(link, (proton.PN_LOCAL_ACTIVE))

        def delivery_iter(link):
            d = proton.pn_unsettled_head(link)
            while d:
                yield d
                d = proton.pn_unsettled_next(d)

        for link in link_iter(conn):
            for d in delivery_iter(link):
                ctx = proton.pn_delivery_get_context(d)
                if isinstance(ctx, str):
                    continue

                disp = proton.pn_delivery_remote_state(d)
                age = time.time() - ctx
                self.log.debug("Checking delivery (%s)",
                               proton.pn_delivery_tag(d))

                if disp and disp != proton.PN_ACCEPTED:
                    self.log.warn("Message was not accepted by remote end")

                if disp and proton.pn_delivery_settled(d):
                    self.log.debug("Message settled by remote end")
                    proton.pn_delivery_settle(d)
                    proton.pn_delivery_clear(d)

                elif age > self._deliveryTimeout:
                    self.log.warn("Delivary not settled by remote host")
                    proton.pn_delivery_settle(d)
                    proton.pn_delivery_clear(d)

                elif proton.pn_link_state(link) & proton.PN_REMOTE_CLOSED:
                    self.log.warn("Link closed before settling message")
                    proton.pn_delivery_settle(d)
                    proton.pn_delivery_clear(d)