Beispiel #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)
Beispiel #2
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 #3
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)
Beispiel #4
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)