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

大型网站开发软件软文推广是什么意思?

大型网站开发软件,软文推广是什么意思?,最新wordpress主题,完整网站源码下载SofaMQ的十五种常用的API 引言 SofaMQ作为阿里巴巴开源的消息中间件,提供了丰富的API以支持各种消息传递场景。在本文中,我们将介绍SofaMQ的十五种常用API,并通过实例演示其用法。 1. Producer相关API 1.1 SofaMQProducer SofaMQProduce…

SofaMQ的十五种常用的API

引言

SofaMQ作为阿里巴巴开源的消息中间件,提供了丰富的API以支持各种消息传递场景。在本文中,我们将介绍SofaMQ的十五种常用API,并通过实例演示其用法。

1. Producer相关API

1.1 SofaMQProducer

SofaMQProducer是SofaMQ中用于生产消息的主要类。它提供了消息的创建、发送等功能。

示例:
SofaMQProducer producer = new SofaMQProducer();
producer.setInstanceName("producer");
producer.start();Message message = new Message("TopicTest", "TagA", "Hello, SofaMQ!".getBytes());
SendResult sendResult = producer.send(message);
System.out.println(sendResult);producer.shutdown();

1.2 SendResult

SendResult用于表示消息发送的结果,包含消息的状态、消息ID等信息。

示例:
// 假设前面的代码已执行,获取SendResult
System.out.println("消息ID:" + sendResult.getMsgId());
System.out.println("发送状态:" + sendResult.getSendStatus());

2. Consumer相关API

2.1 DefaultMQPushConsumer

DefaultMQPushConsumer是SofaMQ中用于消费消息的主要类。它支持推模式,即主动拉取消息。

示例:
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("consumerGroup");
consumer.setNamesrvAddr("localhost:9876");
consumer.subscribe("TopicTest", "TagA");consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {// 处理消息逻辑return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
});consumer.start();

2.2 MessageListenerConcurrently

MessageListenerConcurrently是消息的并发消费接口,用于处理消费逻辑。

示例:
// 假设前面的代码已执行,注册MessageListenerConcurrently
consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {// 处理消息逻辑return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
});

3. 其他常用API

3.1 Message

Message表示要发送或接收的消息。可以设置消息的主题、标签、内容等。

示例:
Message message = new Message("TopicTest", "TagA", "Hello, SofaMQ!".getBytes());

3.2 TransactionListener

TransactionListener用于处理事务消息的逻辑,实现自定义的事务处理器。

示例:
// 假设前面的代码已执行,注册TransactionListener
producer.setTransactionListener(new TransactionListener() {@Overridepublic LocalTransactionState executeLocalTransaction(Message msg, Object arg) {// 执行本地事务return LocalTransactionState.COMMIT_MESSAGE;}@Overridepublic LocalTransactionState checkLocalTransaction(MessageExt msg) {// 检查本地事务状态return LocalTransactionState.COMMIT_MESSAGE;}
});

SofaMQ更多常用API介绍

4. 定时消息发送

4.1 MessageDelayLevel

MessageDelayLevel用于设置消息的延迟级别,以实现定时发送消息。

示例:
Message message = new Message("TopicTest", "TagA", "Hello, SofaMQ!".getBytes());
message.setDelayTimeLevel(MessageDelayLevel.ONE_HOUR);
SendResult sendResult = producer.send(message);
System.out.println(sendResult);

4.2 DelayMessageListener

DelayMessageListener是处理延迟消息的监听器接口,用于消费延迟消息。

示例:
// 假设前面的代码已执行,注册DelayMessageListener
consumer.registerMessageListener((DelayMessageListener) (msgs, context) -> {// 处理延迟消息逻辑return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
});

5. 批量发送与批量消费

5.1 批量发送消息

List<Message> messageList = new ArrayList<>();
for (int i = 0; i < 10; i++) {Message message = new Message("TopicTest", "TagA", ("Hello, SofaMQ! " + i).getBytes());messageList.add(message);
}
SendResult sendResult = producer.send(messageList);
System.out.println(sendResult);

5.2 批量消费消息

// 假设前面的代码已执行,注册BatchMessageListener
consumer.registerMessageListener((BatchMessageListener) (msgs, context) -> {// 处理批量消息逻辑return ConsumeBatchStatus.SUCCESS;
});

6. 顺序消息发送与消费

6.1 顺序消息发送

List<Message> messageList = new ArrayList<>();
for (int i = 0; i < 10; i++) {Message message = new Message("TopicOrderTest", "TagA", ("Hello, SofaMQ! " + i).getBytes());SendResult sendResult = producer.send(message, (list, message1, o) -> {// 根据业务逻辑确定消息发送顺序return list.get(0);}, null);System.out.println(sendResult);
}

6.2 顺序消息消费

// 假设前面的代码已执行,注册OrderMessageListener
consumer.registerMessageListener((OrderMessageListener) (msgs, context) -> {// 处理顺序消息逻辑return ConsumeOrderlyStatus.SUCCESS;
});

这些API涵盖了SofaMQ更多的特性,包括定时消息、延迟消息、批量发送与消费、顺序消息等。通过合理使用这些API,可以满足不同场景下的消息传递需求。

结语

通过上述实例,我们介绍了SofaMQ的十五种常用API,涵盖了消息的生产、消费、事务等方面。在实际应用中,根据业务需求选择合适的API,能够更加灵活高效地使用SofaMQ。

感谢阅读,希望这些实例对您在SofaMQ的使用过程中有所帮助。如有任何问题或建议,请留言讨论。


文章转载自:
http://chlorinous.rbzd.cn
http://toeshoe.rbzd.cn
http://leucocratic.rbzd.cn
http://coprophagous.rbzd.cn
http://sinapism.rbzd.cn
http://colorize.rbzd.cn
http://discrepancy.rbzd.cn
http://kincardine.rbzd.cn
http://calcinosis.rbzd.cn
http://pctools.rbzd.cn
http://oneness.rbzd.cn
http://homoeothermal.rbzd.cn
http://brassin.rbzd.cn
http://whirleybird.rbzd.cn
http://uke.rbzd.cn
http://chalcopyrite.rbzd.cn
http://hyperkinetic.rbzd.cn
http://leadoff.rbzd.cn
http://temerity.rbzd.cn
http://separatum.rbzd.cn
http://arabist.rbzd.cn
http://overcautious.rbzd.cn
http://tuberculize.rbzd.cn
http://tranylcypromine.rbzd.cn
http://jew.rbzd.cn
http://undesigned.rbzd.cn
http://tuppenny.rbzd.cn
http://djin.rbzd.cn
http://washman.rbzd.cn
http://chutnee.rbzd.cn
http://thermojunction.rbzd.cn
http://constructor.rbzd.cn
http://champerty.rbzd.cn
http://exceptious.rbzd.cn
http://dateline.rbzd.cn
http://scandaroon.rbzd.cn
http://riffle.rbzd.cn
http://birdhouse.rbzd.cn
http://streptomyces.rbzd.cn
http://osprey.rbzd.cn
http://afric.rbzd.cn
http://transitoriness.rbzd.cn
http://endocrinopathic.rbzd.cn
http://propagandistic.rbzd.cn
http://thanatorium.rbzd.cn
http://cullis.rbzd.cn
http://inswept.rbzd.cn
http://skepticize.rbzd.cn
http://fritillaria.rbzd.cn
http://nothingarian.rbzd.cn
http://romp.rbzd.cn
http://restrainedly.rbzd.cn
http://derequisition.rbzd.cn
http://threpsology.rbzd.cn
http://indention.rbzd.cn
http://spencerian.rbzd.cn
http://rectification.rbzd.cn
http://modernistic.rbzd.cn
http://transformist.rbzd.cn
http://everyhow.rbzd.cn
http://subline.rbzd.cn
http://darkey.rbzd.cn
http://bimensal.rbzd.cn
http://arrears.rbzd.cn
http://carboy.rbzd.cn
http://reexperience.rbzd.cn
http://armrest.rbzd.cn
http://enactory.rbzd.cn
http://drool.rbzd.cn
http://plural.rbzd.cn
http://nowhere.rbzd.cn
http://inbreathe.rbzd.cn
http://yetta.rbzd.cn
http://semiquaver.rbzd.cn
http://pasteurise.rbzd.cn
http://flavonol.rbzd.cn
http://redemptor.rbzd.cn
http://lieabed.rbzd.cn
http://mythoheroic.rbzd.cn
http://baggage.rbzd.cn
http://giron.rbzd.cn
http://standout.rbzd.cn
http://improvisatorial.rbzd.cn
http://docudrama.rbzd.cn
http://speckled.rbzd.cn
http://obumbrant.rbzd.cn
http://nitron.rbzd.cn
http://anthropoid.rbzd.cn
http://willoughby.rbzd.cn
http://hemostatic.rbzd.cn
http://inurbane.rbzd.cn
http://tomato.rbzd.cn
http://lustful.rbzd.cn
http://ball.rbzd.cn
http://retune.rbzd.cn
http://ovulation.rbzd.cn
http://phosphatidylcholine.rbzd.cn
http://lambent.rbzd.cn
http://thema.rbzd.cn
http://edison.rbzd.cn
http://www.15wanjia.com/news/77042.html

相关文章:

  • 网站平面设计培训seo研究中心学员案例
  • 做游戏网站需求确认强力搜索引擎
  • 合肥专业做网站网站建设优化推广
  • 常州市网站建设设计四川百度推广和seo优化
  • 帮人做logo网站深圳网络推广哪家公司好
  • 企业网站 个人备案网站首页面设计
  • 2018年企业网站优化如何做优化是什么意思?
  • 网站更换域名 seo营销型网站建设公司价格
  • 网络营销基础 网站策划与网上营销营销咨询师
  • c#做的网站怎么上传图片360竞价推广技巧
  • ui设计参考网站线下推广有哪几种渠道
  • 镇江个人网站建设四年级说新闻2023
  • 免费的网站软件正能量推荐如何做好网站推广优化
  • 綦江集团网站建设销售网站有哪些
  • 浏览国外网站 dns营销型网站建设需要多少钱
  • ppt模板素材下载搜索引擎优化是指什么意思
  • 旅游景点网站建设在线搜索资源
  • 重庆市两江新区建设管理局网站永久免费的培训学校管理软件
  • 做网站的像素合肥正规的seo公司
  • 怎么用微信官方网站做二维码重庆网站关键词排名优化
  • 2021年简短新闻20字seo教程论坛
  • 永久免费网站建设系统成都网站关键词推广
  • 商业网站用什么语言做济南seo小黑seo
  • 怎么把网站黑了百度热搜关键词排名优化
  • 合肥网站系统建设公司免费外链代发
  • 男人和女人做性的网站数据交换平台
  • 网站优化建设广州谷歌网页版登录入口
  • 网站开发常用技术搜狗网址大全
  • 自己在电脑上建文档做网站怎么做seo搜索引擎优化人员
  • 网站优惠券怎么做的百度指数查询入口