分两个文件 主脚本mq.sh key文件key.txt,一行一个
#!/bin/bash
mq_host="192.168.0.100:15672"
mq_exchange="TestExchange"
mq_queue="TestQueue"
mq_vhost="%2Fadmin" #/请写%2F
user="admin"
passwd="admin"
cat key.txt|while read payload
do
#properties根据程序需求实际情况填写
curl -XPOST "http://${mq_host}/api/exchanges/${mq_vhost}/${mq_exchange}/publish" -d '{"vhost":"/admin","name":"amq.default","properties":{"delivery_mode":1,"headers":{},"type":"System.String, System.Private.CoreLib"},"routing_key":"'"${mq_queue}"'","delivery_mode":"1","payload":"'"${payload}"'","headers":{},"props":{"type":"System.String, System.Private.CoreLib"},"payload_encoding":"string"}' -u $user:$passwd -H "content-type:application/json"
done
评论区