Beispiel #1
0
def get_qpid():
    global qpid_session
    if qpid_session is None:
        conn = qm.Connection(host=host,
                             port=port,
                             username=user,
                             password=user)
        conn.open()
        qpid_session = conn.session()
    return qpid_session
Beispiel #2
0
    def init(self):
        self.connection = messaging.Connection(self.broker)
        try:
            self.connection.open()
            self.session = self.connection.session()
            self.sender = self.session.sender(self.address)
        except messaging.MessagingError:
            print traceback.format_exc()
            return False

        return True
Beispiel #3
0
    def __init__(self, broker):
        self.closed = False
        self.connection = messaging.Connection(broker)
        self.connection.reconnect = True

        logger.info("[Bus] Connecting to broker %s", broker)
        try:
            self.connection.open()
            logger.info("[Bus] Connected to broker %s", broker)
            self.session = self.connection.session() 
        except messaging.MessagingError, m:
            raise BusException(m)
Beispiel #4
0
    def start(self, queue, daemon=False):
        self.connection = messaging.Connection(self.broker)
        try:
            self.connection.open()
            self.session = self.connection.session()
            self.receiver = self.session.receiver(self.address)
        except messaging.MessagingError:
            print traceback.format_exc()
            return

        thread = Thread(target=self.message_receiver, args=(queue, ))
        thread.setDaemon(daemon)
        thread.start()
Beispiel #5
0
    def reply(broker, address, message):
        connection = messaging.Connection(broker)
        try:
            connection.open()
            session = connection.session()
            sender = session.sender(address)
            sender.send(message)
            session.acknowledge()
        except messaging.MessagingError:
            print traceback.format_exc()
            return False
        finally:
            connection.close()

        return True
Beispiel #6
0
 def connect(self):
     delay = 1
     max_delay = 60
     while True:
         try:
             connection = qm.Connection(self.url, reconnect=False, username=self.username, password=self.password)
             connection.open()
             session = connection.session()
             self.sender = session.sender('%s; {create: always, node: {type: queue, durable: true}}' % self.queue)
             log.info('Shovel connected to QPID')
             return
         except qm.ConnectError:
             log.error('Shovel QPID connection error. Sleep %d seconds', delay)
             time.sleep(delay)
             delay = min(max_delay, delay*2)
Beispiel #7
0
 def __init__(self,
              url,
              queue,
              headers,
              allowed,
              username='******',
              password='******'):
     super(QpidPublisher, self).__init__(allowed)
     self.connection = qm.Connection(url,
                                     reconnect=True,
                                     username=username,
                                     password=password)
     self.queue = queue
     self.session = None
     self.sender = None
     self.headers = headers
     self.connect()
Beispiel #8
0
    def init(self):
        self.connection = messaging.Connection(self.broker)
        try:
            self.connection.open()
            self.session = self.connection.session()
            self.sender = self.session.sender(self.address)
        except messaging.MessagingError:
            print traceback.format_exc()
            return False

        thread = Thread(target=self.ret_msg_processor)
        thread.daemon = True
        thread.start()

        message_receiver = _MessageReceiver(self.broker, self.address_self)
        message_receiver.start(self.ret_msg_queue, daemon=True)

        return True