1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import pika import json
message = {'apiCode': '3005', 'apiUser': '08cs', 'requestIp': '10.4.1.196', 'requestTime': 1726743703912, 'result': 0, 'transactionId': '1a1b47d4-c458-433e-90ca-bde36bd4fcf1'}
message_json = json.dumps(message)
connection = pika.BlockingConnection( pika.ConnectionParameters(host='172.20.30.14') ) channel = connection.channel()
channel.queue_declare(queue='yzf.api.invoke.log.queue', durable=True)
channel.basic_publish( exchange='', routing_key='yzf.api.invoke.log.queue', body=message_json, properties=pika.BasicProperties( delivery_mode=2, ) )
connection.close()
|