def broadcast_client(self, exchange_name, json_data):
     try:
         self.mq_connect()
         self.broad_exchange(exchange_name)
         self.broad_cast(exchange_name, json_data)
         self.mq_disconnect()
     except Exception, e:
         log.error(
             'RabbitMQ broadcast client exec error: exchange=%s, reason=%s'
             % (exchange_name, e))
         raise
Exemplo n.º 2
0
 def rpc_call_server(self, queue_name):
     try:
         self.queue_declare(queue_name)
         self.rbtmq_response = rabbitmq_response.RabbitmqResponse(
             queue_name)
         self.msg_call_request(queue_name)
         self.server_run(queue_name)
     except Exception, e:
         log.error('RabbitMQ call server run error: queue=%s, reason=%s' %
                   (queue_name, e))
         raise
 def rpc_cast_client(self, queue_name, json_data):
     try:
         self.mq_connect()
         self.rpc_cast(queue_name, json_data)
         self.mq_disconnect()
     except Exception, e:
         print 'eeeee'
         print e.args
         print e.message
         log.error('RabbitMQ cast client exec error: queue=%s, reason=%s' %
                   (queue_name, e))
         raise
Exemplo n.º 4
0
 def broadcast_server(self, exchange_name):
     try:
         queue_name = self.broadcast_queue_declare(exchange_name)
         self.rbtmq_response = rabbitmq_response.RabbitmqResponse(
             exchange_name)
         self.msg_broadcast_request(exchange_name, queue_name)
         self.server_run(exchange_name)
     except Exception, e:
         log.error(
             'RabbitMQ broadcast server run error: exchange=%s, reason=%s' %
             (exchange_name, e))
         raise
Exemplo n.º 5
0
    def rpc_exec(self, json_data):
        try:
            response = self.storage_manager.manager(json_data)
            print response

            return response

        except Exception, e:
            print e.message
            print e.args
            log.error('RPC Server exec error: %s' % (e))
            return request_result(599)
    def rpc_call_client(self, queue_name, timeout, json_data):
        try:
            self.mq_connect()
            self.callback_queue()
            self.rpc_call(queue_name, json_data)
            self.get_response(timeout)
            self.mq_disconnect()

            return self.response
        except Exception, e:
            log.error('RabbitMQ call client exec error: queue=%s, reason=%s' %
                      (queue_name, e))
            raise
    def mq_connect(self,
                   mq_server01='boxlinker.com',
                   mq_server02='boxlinker.com'):

        log.debug('Connecting to rabbitmq server, server01=%s, server02=%s' %
                  (mq_server01, mq_server02))

        try:
            self.connection = pika.BlockingConnection(
                pika.ConnectionParameters(host=mq_server01, port=30001))
            self.channel = self.connection.channel()
        except Exception, e:
            log.error('rabbitmq server %s connection error: reason=%s' %
                      (mq_server01, e))
            try:
                self.connection = pika.BlockingConnection(
                    pika.ConnectionParameters(host=mq_server02))
                self.channel = self.connection.channel()
            except Exception, e:
                log.error('rabbitmq server %s connection error: reason=%s' %
                          (mq_server02, e))
                raise