当前位置: 首页 > news >正文

申请网页空间的网站公司简介范本

申请网页空间的网站,公司简介范本,手机装修设计软件app,8一9岁的手工文章目录 批量消息BatchProducer.javaBatchConsumer.java 批量消息 批量发送可以提⾼发送性能#xff0c;但有⼀定的限制#xff1a; topic 相同 waitStoreMsgOK 相同 #xff08;⾸先我们建设消息的iswaitstoremsgoktrue(默认为true), 如果没有异常,我们将始终收到O… 文章目录 批量消息BatchProducer.javaBatchConsumer.java 批量消息 批量发送可以提⾼发送性能但有⼀定的限制 topic 相同 waitStoreMsgOK 相同 ⾸先我们建设消息的iswaitstoremsgoktrue(默认为true), 如果没有异常,我们将始终收到OKorg.apache.rocketmq.common.message.Message#isWaitStoreMsgOK 不支持延时发送 ⼀批消息的大小不能⼤于 4M(DefaultMQProducer.maxMessageSize) 大小限制需要特殊注意因为消息是动态的不注意的话就可能超限就会报错 计算消息的大小 (topic body key value) * N) * 吞吐量 int tmpSize message.getTopic().length() message.getBody().length; MapString, String properties message.getProperties(); for (Map.EntryString, String entry : properties.entrySet()) {tmpSize entry.getKey().length() entry.getValue().length(); }BatchProducer.java package com.example.rocketmq.demo.batch;import org.apache.rocketmq.client.producer.DefaultMQProducer; import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.common.message.Message;import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map;public class BatchProducer {public static void main(String[] args) throws Exception {//Instantiate with a producer group name.DefaultMQProducer producer newDefaultMQProducer(please_rename_unique_group_name);// Specify name server addresses.producer.setNamesrvAddr(localhost:9876);//Launch the instance.producer.start();String topic TopicTest;ListMessage messages new ArrayList();messages.add(new Message(topic, TagA, OrderID001, Hello world 0.getBytes()));messages.add(new Message(topic, TagA, OrderID002, Hello world 1.getBytes()));messages.add(new Message(topic, TagA, OrderID003, Hello world 2.getBytes()));//then you could split the large list into small ones:ListSplitter splitter new ListSplitter(messages);while (splitter.hasNext()) {try {ListMessage listItem splitter.next();SendResult sendResult producer.send(listItem);System.out.printf(%s%n, sendResult);} catch (Exception e) {e.printStackTrace();//handle the error}}//Shut down once the producer instance is not longer in use.producer.shutdown();} }class ListSplitter implements IteratorListMessage {private final int SIZE_LIMIT 1024 * 1024 * 4;private final ListMessage messages;private int currIndex;public ListSplitter(ListMessage messages) {this.messages messages;}Override public boolean hasNext() {return currIndex messages.size();}Override public ListMessage next() {int nextIndex currIndex;int totalSize 0;for (; nextIndex messages.size(); nextIndex) {Message message messages.get(nextIndex);//计算消息的大小 (topic body key value) * N) * 吞吐量int tmpSize message.getTopic().length() message.getBody().length;//属性值的添加MapString, String properties message.getProperties();for (Map.EntryString, String entry : properties.entrySet()) {//key valuetmpSize entry.getKey().length() entry.getValue().length();}tmpSize tmpSize 20; //for log overheadif (tmpSize SIZE_LIMIT) {//it is unexpected that single message exceeds the SIZE_LIMIT//here just let it go, otherwise it will block the splitting processif (nextIndex - currIndex 0) {//if the next sublist has no element, add this one and then break, otherwise just breaknextIndex;}break;}if (tmpSize totalSize SIZE_LIMIT) {break;} else {totalSize tmpSize;}}ListMessage subList messages.subList(currIndex, nextIndex);currIndex nextIndex;return subList;} } BatchConsumer.java package com.example.rocketmq.demo.batch;import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.common.message.MessageExt;import java.util.List;public class BatchConsumer {public static void main(String[] args) throws InterruptedException, MQClientException {// Instantiate with specified consumer group name.DefaultMQPushConsumer consumer new DefaultMQPushConsumer(please_rename_unique_group_name);// Specify name server addresses.consumer.setNamesrvAddr(localhost:9876);// Subscribe one more more topics to consume.consumer.subscribe(TopicTest, *);// Register callback to execute on arrival of messages fetched from brokers.consumer.registerMessageListener(new MessageListenerConcurrently() {Overridepublic ConsumeConcurrentlyStatus consumeMessage(ListMessageExt msgs,ConsumeConcurrentlyContext context) {System.out.printf(%s Receive New Messages: %s %n, Thread.currentThread().getName(), msgs);return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;}});//Launch the consumer instance.consumer.start();System.out.printf(Consumer Started.%n);} }
http://www.hkea.cn/news/14256179/

相关文章:

  • 怎么想百度提交网站网站做访问追踪
  • 公司网站制作怎么弄东莞市非凡网站建设
  • 怎么做消费信贷网站嘉兴网站系统总部
  • 天门网站建设wordpress头像尺寸
  • 手表网站推荐做网站建设哪家公司好
  • 如何用html做网站头像百度山西网站建设和百度推广
  • 哈尔滨定制网站建设潍坊网站建设推广报价
  • 怎么把现有网站开发php外贸网站推广外包
  • 网站对公司的意义外贸管理软件有哪些
  • 网站到处仿wordpress装饰
  • 网站检测中心俄罗斯做牙网站
  • 平度网站建设公司电话阿里云官网
  • 网站改版策划方案小程序制作卡片列表
  • 哪个网站diy做宝宝衣服合肥seo推广培训班
  • 做网站的素材包含哪些php做网站优点
  • 网页网站怎么做的哈尔滨网站seo
  • 广州城市建设规划局网站wordpress自动链接到图片
  • 西安网站建设个人长春教做网站带维护的培训机构
  • 河北省城乡住房和建设厅网站浙江平台网站建设哪家有
  • 建设部政务网站wordpress 虎嗅
  • 哈尔滨网站域名备案做亚马逊需要的图片外链网站
  • 网络营销网站建设ppt大兴德艺网站建设
  • 顺德微信网站建设广东上海专业网站建设公司
  • 网站cps后台怎么做公司网站建设重点内容
  • 学校免费网站建设安徽省建设工程造价管理网站
  • 卡密提取网站怎么做网站建设的功能定位
  • iis 多网站安全设置本机建的网站打开却很慢
  • 南部县网站建设励志网站织梦源码
  • 公司营业执照可以做几个网站交友高端网站建设
  • 邢台集团网站建设报价网站建设用阿里还是华为云