RabbitMQ预取(RabbitMQ Prefetch)
到目前为止,我的RabbitMQ消费者客户端使用的预取值为1.我希望增加该值以获得性能。 如果我将值设置为2,RabbitMQ服务器是否会一次向每个消费者发送2条消息,这样我将需要解析这两条消息并将第二条消息存储在List中,直到第一条消息被处理并确认为止? 或者API会在幕后处理吗?
我正在使用Java AMQP客户端库:
ConnectionFactory factory = new ConnectionFactory(); ... Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.basicQos(2); QueueingConsumer consumer = new QueueingConsumer(channel); channel.basicConsume(CONSUME_QUEUE_NAME, false, consumer); while (!Thread.currentThread().isInterrupted()) { try { QueueingConsumer.Delivery delivery = consumer.nextDelivery(); String m = new String(delivery.getBody(), "UTF-8"); // Will m contain two messages? Will I have to each message and keep track of them within a List? ... }
Up until now, my RabbitMQ consumer clients have used a prefetch value of 1. I'm looking to increase the value in order to gain performance. If I set the value to 2, will the RabbitMQ server send each consumer 2 messages at once such that I will need to parse the two messages and store the second one in a List until the first is processed and acknowledged? Or will the API handle this behind the scenes?
I'm using the Java AMQP client library:
ConnectionFactory factory = new ConnectionFactory(); ... Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.basicQos(2); QueueingConsumer consumer = new QueueingConsumer(channel); channel.basicConsume(CONSUME_QUEUE_NAME, false, consumer); while (!Thread.currentThread().isInterrupted()) { try { QueueingConsumer.Delivery delivery = consumer.nextDelivery(); String m = new String(delivery.getBody(), "UTF-8"); // Will m contain two messages? Will I have to each message and keep track of them within a List? ... }
原文:
更新时间:2022-09-25 10:09
最满意答案
使用正则表达式的
preg_match()
函数:<?php $url = 'example.com/names/steve'; echo (preg_match("/names/i", $url)) ? 'Match' : 'No Match'; ?>
所以对于你的例子试试这个:
if (is_page(1111) || preg_match("/\/names\//", $_SERVER['REQUEST_URI'])){ // your logic }
With
preg_match()
function using regular expression:<?php $url = 'example.com/names/steve'; echo (preg_match("/names/i", $url)) ? 'Match' : 'No Match'; ?>
so for your example try this:
if (is_page(1111) || preg_match("/\/names\//", $_SERVER['REQUEST_URI'])){ // your logic }
相关问答
更多-
这条规则正是你所需要的:
如何在IIS UrlRewrite中设置条件以检查URL是否有效(How to set a condition in IIS UrlRewrite to check if the URL is valid)[2022-04-08]
该规则将example.local/this_doesnt_exist重定向到example.local/current_work :当然,只是利用重写在评估中排序的事实: RewriteRule ^/ichat/special/(.+) /chat.php?special=yes&chatid=$1 [L] RewriteRule ^/ichat/(.+) /chat.php?chatid=$1 [L] [L]意味着规则评估将在规则处停止,如果它匹配,那么任何/ichat/special/ url将被第一个规则捕获,而其他/ichat/ url将被第二个规则捕获。 Sure, just take advantage of the fa ...如果你看看如何使用server_api : _.each(_.result(self, "server_api"), function(value, key){ if( _.isFunction(value) ) { value = _.bind(value, self); value = value(); } queryAttributes[key] = value; }); 你会看到它使用_.result : 结果 _.result(object, property) 如果 ...获取URL参数条件(Get URL parameters condition)[2022-06-09]
当你要发起请求时,你能使用字符串构建器吗? $scope.search=function(name,date){ var requestParams = '?'; if(name) requestParams += "name= " + name; if(name && date) requestParams += "&" if(date) requestParams += "start_date_from=" + date; // you may want ...基于URL的Rails条件(Rails condition based on URL)[2021-11-05]
查询参数在每个请求的params哈希中可用: <% if "elite" == params[:t] %>Check it out<% end %> Query parameters are available in the params Hash on each request: <% if "elite" == params[:t] %>Check it out<% end %>试试这个正则表达式: (?带有条件的IMPORTRANGE(IMPORTRANGE with condition)[2022-02-17]
我在下面的电子表格中添加了一些示例: 例如= QUERY(IMPORTRANGE(“ https://docs.google.com/spreadsheets/d/1LX7JfbGvgBTfmXsYZz0u7J7K0O6oHJSnBowKQJGa9lY/edit#gid=0 ”,“Inc Database!A2:B300”),“SELECT Col1 WHERE not(Col2 ='Permanent ')“) I have put a few examples in the following spre ...检查url是否有条件(Check url for if condition)[2023-07-22]
使用正则表达式的preg_match()函数: 所以对于你的例子试试这个: if (is_page(1111) || preg_match("/\/names\//", $_SERVER['REQUEST_URI'])){ // your logic } With preg_ma ...我们可否在servlet-filter的url映射中没有条件(Can we have NOT condition in url-mapping for servlet-filter)[2021-10-02]
不,这是不可能的。 你可以在你的过滤器中添加这个条件,并只做chain.doFilter(req, resp) (即跳过过滤器)。 No, it is not possible. You can add this condition in your filter and do just chain.doFilter(req, resp) (i.e. skip the filter).相关文章
更多- RabbitMQ 简介
- RabbitMQ 插件管理
- RabbitMQ 集群搭建
- RabbitMQ 环境配置-基于linux
- RabbitMQ vhost管理
- RabbitMQ 简单队列
- RabbitMQ 用户管理
- RabbitMQ 与Spring整合
- RabbitMQ 消息确认方式
- RabbitMQ topic Exchange使用
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)