ActiveMQ-限制订阅的数量

时间:2019-07-03 13:57:07

标签: activemq activemq-artemis

我遇到一个问题,一个客户(通过错误的方式)在同一主题上(通过约100个连接)订阅了4000多个时间。这导致ActiveMQ的资源非常低,并且变得非常慢。

是否存在某种防止这种情况发生的机制?像一个客户/用户可以在一个主题上最多订阅X次?

1 个答案:

答案 0 :(得分:0)

我不知道ActiveMQ 5.x中的任何功能都可以提供您想要的功能。

但是,ActiveMQ Artemis有per-user resource limits。因此,如果您的经纪人受到保护,使得客户端必须使用用户名和密码(应该是用户名和密码)进行连接,那么您可以在var fs = require('fs'); var Jimp = require('jimp'); // User-Defined Function to read the images var json = fs.readFileSync('json2.txt', 'utf8'); //var json = '[{"Name":"image1.png","crops":[{"x":0,"y":53.29014916901091,"width":880,"height":502.44997787924575}]},{"Name":"image2.png","crops":[{"x":0,"y":8.616125016979977,"width":498,"height":350.3890840238524},{"x":0,"y":371.92939656630233,"width":498,"height":139.29402110784292}]},{"Name":"image3.jpg","crops":[{"x":0,"y":12.711224291602823,"width":232,"height":60.211062433908104},{"x":0,"y":65.56315687247772,"width":232,"height":109.04892418585581}]},{"Name":"image44.png","crops":[{"x":0,"y":124.83500957409233,"width":548,"height":453.5145284527152},{"x":0,"y":225.9671692290532,"width":548,"height":178.56146939079028}]}]' // '[{"Name":"image2.png","crops":[{"x":0,"y":7.180104180816647,"width":498,"height":348.953063187689},{"x":0,"y":359.00520904083237,"width":498,"height":150.78218779714956}]},{"Name":"image4 - Copy.png","crops":[{"x":0,"y":140.63690952017996,"width":548,"height":404.5286386198435}]}]'; var array = JSON.parse(json); async function main() { for(var i = 0; i < array.length; i++){ var imagePath = 'E:\\myProjects 4 98\\project1\\assets\\Imgs\\' + array[i].Name; for (var j = 0; j < array[i].crops.length; j++){ const image = await Jimp.read(imagePath); var imageName = array[i].Name.replace(/\.(.*?)$/g, ''); var cropName = imageName + '_' + j; image.crop(array[i].crops[j].x, array[i].crops[j].y, array[i].crops[j].width, array[i].crops[j].height) .write(cropName + '.jpg'); } } } main(); console.log("Image Processing Completed"); 中使用类似这样的方式来强制使用每次连接限制:

broker.xml

还值得注意的是,当消费者在某个主题上创建订阅时,则会创建一个队列,其中包含该订阅的所有消息。您可以使用<resource-limit-settings> <resource-limit-setting match="myUser"> <max-connections>5</max-connections> </resource-limit-setting> </resource-limit-settings> config参数来限制用户可以创建的队列数(从而限制订阅数),例如:

max-queues