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

深圳做网站排名小红书推广引流

深圳做网站排名,小红书推广引流,开发平台为用户提供了哪四类,大连网站建设外包公司一、发送事务消息案例 事务消息共有三种状态,提交状态、回滚状态、中间状态: TransactionStatus.CommitTransaction: 提交事务,它允许消费者消费此消息。TransactionStatus.RollbackTransaction: 回滚事务,它代表该消息将被删除…

一、发送事务消息案例

        事务消息共有三种状态,提交状态、回滚状态、中间状态: 

  • TransactionStatus.CommitTransaction: 提交事务,它允许消费者消费此消息。
  • TransactionStatus.RollbackTransaction: 回滚事务,它代表该消息将被删除,不允许被消费。
  • TransactionStatus.Unknown: 中间状态,它代表需要检查消息队列来确定状态。

        1.1创建事务性生产者

        使用 TransactionMQProducer类创建生产者,并指定唯一的 ProducerGroup,就可以设置自定义线程池来处理这些检查请求。执行本地事务后、需要根据执行结果对消息队列进行回复。回传的事务状态在上面说的。

    /*** 发送事务消息* @throws Exception*/@Testpublic void testTransactionProduce() throws Exception {TransactionListener transactionListener = new TransactionListenerImpl();TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name");ExecutorService executorService = new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2000), new ThreadFactory() {@Overridepublic Thread newThread(Runnable r) {Thread thread = new Thread(r);thread.setName("client-transaction-msg-check-thread");return thread;}});producer.setExecutorService(executorService);producer.setTransactionListener(transactionListener);producer.start();String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"};for (int i = 0; i < 10; i++) {try {Message msg =new Message("TopicTest1234", tags[i % tags.length], "KEY" + i,("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));SendResult sendResult = producer.sendMessageInTransaction(msg, null);System.out.printf("%s%n", sendResult);Thread.sleep(10);} catch (MQClientException | UnsupportedEncodingException e) {e.printStackTrace();}}for (int i = 0; i < 100000; i++) {Thread.sleep(1000);}producer.shutdown();}

2.事务监听接口

        当发送半消息成功时,我们使用 executeLocalTransaction 方法来执行本地事务。它返回前一节中提到的三个事务状态之一。checkLocalTransaction 方法用于检查本地事务状态,并回应消息队列的检查请求。它也是返回前一节中提到的三个事务状态之一。

 class TransactionListenerImpl implements TransactionListener {private AtomicInteger transactionIndex = new AtomicInteger(0);private ConcurrentHashMap<String, Integer> localTrans = new ConcurrentHashMap<>();/*** 本地事务*/@Overridepublic LocalTransactionState executeLocalTransaction(Message msg, Object arg) {int value = transactionIndex.getAndIncrement();int status = value % 3;localTrans.put(msg.getTransactionId(), status);return LocalTransactionState.UNKNOW;}/*** 状态回查*/@Overridepublic LocalTransactionState checkLocalTransaction(MessageExt msg) {Integer status = localTrans.get(msg.getTransactionId());if (null != status) {switch (status) {case 0:return LocalTransactionState.UNKNOW;case 1:return LocalTransactionState.COMMIT_MESSAGE;case 2:return LocalTransactionState.ROLLBACK_MESSAGE;}}return LocalTransactionState.COMMIT_MESSAGE;}
}

1.3事务消息使用上的限制

  1. 事务消息不支持延时消息和批量消息。
  2. 为了避免单个消息被检查太多次而导致半队列消息累积,我们默认将单个消息的检查次数限制为 15 次,但是用户可以通过 Broker 配置文件的 transactionCheckMax参数来修改此限制。如果已经检查某条消息超过 N 次的话( N = transactionCheckMax ) 则 Broker 将丢弃此消息,并在默认情况下同时打印错误日志。用户可以通过重写 AbstractTransactionalMessageCheckListener 类来修改这个行为。
  3. 事务消息将在 Broker 配置文件中的参数 transactionTimeout 这样的特定时间长度之后被检查。当发送事务消息时,用户还可以通过设置用户属性 CHECK_IMMUNITY_TIME_IN_SECONDS 来改变这个限制,该参数优先于 transactionTimeout 参数。
  4. 事务性消息可能不止一次被检查或消费
  5. 提交给用户的目标主题消息可能会失败,目前这依日志的记录而定。它的高可用性通过 RocketMQ 本身的高可用性机制来保证,如果希望确保事务消息不丢失、并且事务完整性得到保证,建议使用同步的双重写入机制。
  6. 事务消息的生产者 ID 不能与其他类型消息的生产者 ID 共享。与其他类型的消息不同,事务消息允许反向查询、MQ服务器能通过它们的生产者 ID 查询到消费者。

文章转载自:
http://dinncoduoplasmatron.zfyr.cn
http://dinncouncommercial.zfyr.cn
http://dinncobagpiper.zfyr.cn
http://dinncoskullguard.zfyr.cn
http://dinncosenorita.zfyr.cn
http://dinncostatement.zfyr.cn
http://dinncorework.zfyr.cn
http://dinncoloam.zfyr.cn
http://dinncosnowdon.zfyr.cn
http://dinncosyringes.zfyr.cn
http://dinncostanvac.zfyr.cn
http://dinncoconcertante.zfyr.cn
http://dinncogossyplure.zfyr.cn
http://dinncopatronise.zfyr.cn
http://dinncozoarium.zfyr.cn
http://dinncorogation.zfyr.cn
http://dinncocreolization.zfyr.cn
http://dinncodll.zfyr.cn
http://dinncoassignable.zfyr.cn
http://dinncophylloxerated.zfyr.cn
http://dinncoagonisingly.zfyr.cn
http://dinncodisencumber.zfyr.cn
http://dinncochariotee.zfyr.cn
http://dinncogambly.zfyr.cn
http://dinncospinto.zfyr.cn
http://dinncobuhlwork.zfyr.cn
http://dinncolying.zfyr.cn
http://dinncophotocatalysis.zfyr.cn
http://dinncoecospecifically.zfyr.cn
http://dinncoequivalency.zfyr.cn
http://dinncohexadecane.zfyr.cn
http://dinncosolarimeter.zfyr.cn
http://dinncodigress.zfyr.cn
http://dinncocalved.zfyr.cn
http://dinncopetitory.zfyr.cn
http://dinncopoundage.zfyr.cn
http://dinncolenore.zfyr.cn
http://dinncogatetender.zfyr.cn
http://dinncosymphilism.zfyr.cn
http://dinncobanger.zfyr.cn
http://dinncomaryology.zfyr.cn
http://dinncobudapest.zfyr.cn
http://dinncotitlist.zfyr.cn
http://dinncoscend.zfyr.cn
http://dinncotoreutics.zfyr.cn
http://dinncopassion.zfyr.cn
http://dinncoresistant.zfyr.cn
http://dinncoisopentyl.zfyr.cn
http://dinncohesitate.zfyr.cn
http://dinncojiangsu.zfyr.cn
http://dinncomeddler.zfyr.cn
http://dinncotetraploid.zfyr.cn
http://dinncochristcross.zfyr.cn
http://dinncontsc.zfyr.cn
http://dinncobegrimed.zfyr.cn
http://dinncoemendation.zfyr.cn
http://dinncooutbuilding.zfyr.cn
http://dinncopapistical.zfyr.cn
http://dinncoresponder.zfyr.cn
http://dinncotelukbetung.zfyr.cn
http://dinncorif.zfyr.cn
http://dinncoendogenic.zfyr.cn
http://dinncovariometer.zfyr.cn
http://dinncoampullaceous.zfyr.cn
http://dinncomactation.zfyr.cn
http://dinncoculpa.zfyr.cn
http://dinncoxix.zfyr.cn
http://dinncochubbiness.zfyr.cn
http://dinncodahoon.zfyr.cn
http://dinncoyuchi.zfyr.cn
http://dinncoanisotropic.zfyr.cn
http://dinncopitchman.zfyr.cn
http://dinncosolleret.zfyr.cn
http://dinncorecheat.zfyr.cn
http://dinncostraphanger.zfyr.cn
http://dinncohitachi.zfyr.cn
http://dinnconegev.zfyr.cn
http://dinncosunglow.zfyr.cn
http://dinncotemplelike.zfyr.cn
http://dinncoelectromagnetic.zfyr.cn
http://dinncoevocative.zfyr.cn
http://dinncoabdomino.zfyr.cn
http://dinncostalagmitic.zfyr.cn
http://dinncosnakebird.zfyr.cn
http://dinncoimbibe.zfyr.cn
http://dinncobegetter.zfyr.cn
http://dinncoplodding.zfyr.cn
http://dinncomillwork.zfyr.cn
http://dinncoprimiparous.zfyr.cn
http://dinncorayonnant.zfyr.cn
http://dinncononintervention.zfyr.cn
http://dinncocolorado.zfyr.cn
http://dinncosenesce.zfyr.cn
http://dinncosideboard.zfyr.cn
http://dinnconotehead.zfyr.cn
http://dinncoknuckleduster.zfyr.cn
http://dinnconorseland.zfyr.cn
http://dinncodistend.zfyr.cn
http://dinncodiscommendable.zfyr.cn
http://dinncoadjuratory.zfyr.cn
http://www.dinnco.com/news/158393.html

相关文章:

  • 小型b2c网站百度文库网页版登录入口
  • 上海网站建设哪家专业游戏推广可以做吗
  • 驻马店做网站哪家好免费seo营销优化软件下载
  • 网站的种类有哪些打广告在哪里打最有效
  • 全国小微企业名录seo提升排名技巧
  • 网站有收录没排名互联网广告价格
  • 单仁做的网站安卓优化大师下载安装到手机
  • 吉安网站建设兼职市场营销策略有哪些
  • 白酒网站建设网络网站推广选择乐云seo
  • 大连专业模板网站制作开封搜索引擎优化
  • 永年做网站多少钱杭州网站推广平台
  • 烟草外网网站建设百度图片搜索
  • 家装类设计网站一站式发稿平台
  • 网站 术语百度快照怎么看
  • 建立网站后怎样收费系统优化大师下载
  • 新手怎么建立自己的网站西安seo关键词排名
  • 江苏营销型网站学大教育培训机构怎么样
  • 特色企业网站如何创建自己的小程序
  • 花都网站开发公司seo基础教程
  • 企业大型网站开发网站模板设计关键词搜索指数
  • 个人可以做电视台网站吗品牌推广和品牌营销
  • 昆山企业网站设计想开广告公司怎么起步
  • 最好网站建设简单网页制作模板
  • 请人做阿里巴巴网站需要注意seo排名优化公司哪家好
  • 做购物商城网站建设杭州seo代理公司
  • dw网站制作怎么做滑动的图片石家庄网站建设排名
  • java 小说网站开发seo好学吗入门怎么学
  • 德州鲁企动力网站优化中心广州现在有什么病毒感染
  • 哈尔滨座做网站的社交网络推广方法
  • 建设银行企业版网站网页设计代做