‘ % 信息 # 相反 </跨度> 消息并将其发回 打印’发回消息:%s’%消息[:: - 1]
#pika发送消息 进口鼠兔 connection =pika.BlockingConnection ) self.write_message(体) time.sleep(4) body_obj = json.loads(正文) 如果正文中有’消息’: if body_obj [‘message’] ==“ 裂纹 </跨度>
尝试使用此代码:
https://github.com/Gsantomaggio/rabbitmqexample/tree/master/webSocketPython
def threaded_rmq(): channel.queue_declare(queue="my_queue") logging.info('consumer ready, on my_queue') channel.basic_consume(consumer_callback, queue="my_queue", no_ack=True) channel.start_consuming()
和 if __name__ == "__main__": logging.info('Starting thread RabbitMQ') threadRMQ = Thread(target=threaded_rmq) threadRMQ.start()
if __name__ == "__main__": logging.info('Starting thread RabbitMQ') threadRMQ = Thread(target=threaded_rmq) threadRMQ.start()