Пример #1
0
def cast(name, message, service=False):
    logger.debug(
        "RPC cast to orchestrator:\n{0}".format(
            jsonutils.dumps(message, indent=4)
        )
    )
    #测试使用
    file_object = open('/opt/queuemsg.txt', 'w')
    file_object.write(jsonutils.dumps(message, indent=4))
    file_object.close()
    

    use_queue = naily_queue if not service else naily_service_queue
    use_exchange = naily_exchange if not service else naily_service_exchange
    with Connection(conn_str) as conn:
        with conn.Producer(serializer='json') as producer:
            publish = functools.partial(producer.publish, message,
                exchange=use_exchange, routing_key=name, declare=[use_queue])
            try:
                #pass
                publish()
            except amqp_exceptions.PreconditionFailed as e:
                logger.warning(six.text_type(e))
                # (dshulyak) we should drop both exchanges/queues in order
                # for astute to be able to recover temporary queues
                utils.delete_entities(
                    conn, naily_service_exchange, naily_service_queue,
                    naily_exchange, naily_queue)
                publish()
Пример #2
0
def cast(name, message, service=False):
    logger.debug("RPC cast to orchestrator:\n{0}".format(
        jsonutils.dumps(message, indent=4)))
    #测试使用
    file_object = open('/opt/queuemsg.txt', 'w')
    file_object.write(jsonutils.dumps(message, indent=4))
    file_object.close()

    use_queue = naily_queue if not service else naily_service_queue
    use_exchange = naily_exchange if not service else naily_service_exchange
    with Connection(conn_str) as conn:
        with conn.Producer(serializer='json') as producer:
            publish = functools.partial(producer.publish,
                                        message,
                                        exchange=use_exchange,
                                        routing_key=name,
                                        declare=[use_queue])
            try:
                #pass
                publish()
            except amqp_exceptions.PreconditionFailed as e:
                logger.warning(six.text_type(e))
                # (dshulyak) we should drop both exchanges/queues in order
                # for astute to be able to recover temporary queues
                utils.delete_entities(conn, naily_service_exchange,
                                      naily_service_queue, naily_exchange,
                                      naily_queue)
                publish()
Пример #3
0
def cast(name, message, service=False):
    logger.debug("RPC cast to orchestrator:\n{0}".format(
        json.dumps(message, indent=4)))
    use_queue = naily_queue if not service else naily_service_queue
    use_exchange = naily_exchange if not service else naily_service_exchange
    with Connection(conn_str) as conn:
        with conn.Producer(serializer='json') as producer:
            publish = functools.partial(producer.publish,
                                        message,
                                        exchange=use_exchange,
                                        routing_key=name,
                                        declare=[use_queue])
            try:
                publish()
            except amqp_exceptions.PreconditionFailed as e:
                logger.warning(six.text_type(e))
                utils.delete_entities(conn, use_exchange, use_queue)
                publish()
Пример #4
0
def cast(name, message, service=False):
    logger.debug(
        "RPC cast to orchestrator:\n{0}".format(
            jsonutils.dumps(message, indent=4)
        )
    )
    use_queue = naily_queue if not service else naily_service_queue
    use_exchange = naily_exchange if not service else naily_service_exchange
    with Connection(conn_str) as conn:
        with conn.Producer(serializer='json') as producer:
            publish = functools.partial(producer.publish, message,
                exchange=use_exchange, routing_key=name, declare=[use_queue])
            try:
                publish()
            except amqp_exceptions.PreconditionFailed as e:
                logger.warning(six.text_type(e))
                utils.delete_entities(conn, use_exchange, use_queue)
                publish()
Пример #5
0
 def on_precondition_failed(self, error_msg):
     logger.warning(error_msg)
     utils.delete_entities(
         self.connection, rpc.nailgun_exchange, rpc.nailgun_queue)
Пример #6
0
 def on_precondition_failed(self, error_msg):
     logger.warning(error_msg)
     utils.delete_entities(self.connection, rpc.nailgun_exchange,
                           rpc.nailgun_queue)