批量给rabbitmq灌数据

Z先森 2022-02-23 AM 717℃ 0条

分两个文件
主脚本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
标签: none

如无特殊说明,本博所有文章均为博主原创。

评论啦~