Exemple #1
0
    def _openLinks(self, conn):
        link = proton.pn_link_head(conn, proton.PN_LOCAL_UNINIT)
        while link:
            self.log.debug("Opening Link")
            proton.pn_terminus_copy(proton.pn_link_source(link),
                                    proton.pn_link_remote_source(link))
            proton.pn_terminus_copy(proton.pn_link_target(link),
                                    proton.pn_link_remote_target(link))

            ssn = proton.pn_link_session(link)
            client = proton.pn_session_get_context(ssn)
            if proton.pn_link_is_sender(link):
                if client.sender != link:
                    self.log.debug("Already have a sender opened for session")
                    proton.pn_link_close(link)
                else:
                    self.log.debug("Opening Link to send messages")
                    proton.pn_link_open(link)

            elif proton.pn_link_is_receiver(link):
                self.log.debug("Opening Link to recv messages")
                proton.pn_link_open(link)
                proton.pn_link_flow(link, MBUFF_SIZE)

            link = proton.pn_link_next(link, proton.PN_LOCAL_UNINIT)
Exemple #2
0
    def _openLinks(self, conn):
        link = proton.pn_link_head(conn, proton.PN_LOCAL_UNINIT)
        while link:
            self.log.debug("Opening Link")
            proton.pn_terminus_copy(proton.pn_link_source(link),
                                    proton.pn_link_remote_source(link))
            proton.pn_terminus_copy(proton.pn_link_target(link),
                                    proton.pn_link_remote_target(link))

            ssn = proton.pn_link_session(link)
            client = proton.pn_session_get_context(ssn)
            if proton.pn_link_is_sender(link):
                if client.sender != link:
                    self.log.debug("Already have a sender opened for session")
                    proton.pn_link_close(link)
                else:
                    self.log.debug("Opening Link to send messages")
                    proton.pn_link_open(link)

            elif proton.pn_link_is_receiver(link):
                self.log.debug("Opening Link to recv messages")
                proton.pn_link_open(link)
                proton.pn_link_flow(link, MBUFF_SIZE)

            link = proton.pn_link_next(link, proton.PN_LOCAL_UNINIT)
Exemple #3
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))
Exemple #4
0
    def _cleanLinks(self, conn):
        link = proton.pn_link_head(conn, (proton.PN_LOCAL_ACTIVE |
                                          proton.PN_REMOTE_CLOSED))
        while link:
            self.log.debug("Closing Link")
            proton.pn_link_close(link)
            ssn = proton.pn_link_session(link)
            client = proton.pn_session_get_context(ssn)
            if link == client.sender:
                client.sender = None

            link = proton.pn_link_next(link, (proton.PN_LOCAL_ACTIVE |
                                              proton.PN_REMOTE_CLOSED))
Exemple #5
0
    def _cleanLinks(self, conn):
        link = proton.pn_link_head(
            conn, (proton.PN_LOCAL_ACTIVE | proton.PN_REMOTE_CLOSED))
        while link:
            self.log.debug("Closing Link")
            proton.pn_link_close(link)
            ssn = proton.pn_link_session(link)
            client = proton.pn_session_get_context(ssn)
            if link == client.sender:
                client.sender = None

            link = proton.pn_link_next(
                link, (proton.PN_LOCAL_ACTIVE | proton.PN_REMOTE_CLOSED))
Exemple #6
0
    def _cleanLinks(self, conn):
        link = proton.pn_link_head(conn, (proton.PN_LOCAL_ACTIVE |
                                          proton.PN_REMOTE_CLOSED))
        while link:
            self.log.debug("Closing Link")
            proton.pn_link_close(link)
            for ctx in self._sessionContexts:
                if link in ctx.links:
                    ctx.links.remove(link)

                if link == ctx.sender:
                    ctx.sender = None

            link = proton.pn_link_next(link, (proton.PN_LOCAL_ACTIVE |
                                              proton.PN_REMOTE_CLOSED))
Exemple #7
0
    def _openLinks(self, conn):
        link = proton.pn_link_head(conn, proton.PN_LOCAL_UNINIT)
        while link:
            self.log.debug("Opening Link")
            proton.pn_terminus_copy(proton.pn_link_source(link),
                                    proton.pn_link_remote_source(link))
            proton.pn_terminus_copy(proton.pn_link_target(link),
                                    proton.pn_link_remote_target(link))

            ssn = proton.pn_link_session(link)
            if proton.pn_link_is_sender(link):
                for ctx in self._sessionContexts:
                    if ctx['session'] != ssn:
                        continue

                    ctx['links'].append(link)
                self.log.debug("Opening Link to send Events")

            if proton.pn_link_is_receiver(link):
                self.log.debug("Opening Link to recv messages")
                proton.pn_link_flow(link, 1)

            proton.pn_link_open(link)
            link = proton.pn_link_next(link, proton.PN_LOCAL_UNINIT)
Exemple #8
0
 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))
Exemple #9
0
 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))