RocketMQ下载、安装、以及结合Springboot的使用
2021-03-07 17:28
标签:enc temp shutdown srv value ext dem log roc 消息队列的应用场景:主要用于处理高并发作削峰处理、业务解耦等,比如说 大规模的短信推送、订单抓取、库存同步、消息同步等。 wget https://archive.apache.org/dist/rocketmq/4.5.1/rocketmq-all-4.5.1-bin-release.zip unzip rocketmq-all-4.5.1-bin-release.zip cd rocketmq-all-4.5.1-bin-release/bin nohup sh mqnamesrv & tail -f ~/logs/rocketmqlogs/namesrv.log # 如果成功启动,能看到类似如下的日志: nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true & tail -f ~/logs/rocketmqlogs/broker.log # 如果启动成功,能看到类似如下的日志: sh mqshutdown namesrv 如果一直报错 172.17.0.11:10911 连接失败,需要新增ip配置文件并指定 brokerIP1=xxx nohup sh mqbroker -n 172.17.0.11:9876 autoCreateTopicEnable=true -c conf/broker.conf & RocketMQ下载、安装、以及结合Springboot的使用 标签:enc temp shutdown srv value ext dem log roc 原文地址:https://www.cnblogs.com/pzyin/p/14263188.html业务应用场景
下载
安装
启动
启动nameServer、并验证
2019-07-18 17:03:56 INFO main - The Name Server boot success. ...启动Broker 并验证 (如果启动失败,调整内存参数)
2019-07-18 17:08:41 INFO main - The broker[itmuchcomdeMacBook-Pro.local, 192.168.43.197:10911] boot success. serializeType=JSON and name server is localhost:9876关闭MQ
注意实战
pom依赖
发送消息
@Resource
private RocketMQTemplate rocketMQTemplate;
@Value("${pet.topic.order}")
private String orderTopic;
@Scheduled(cron = "0 0 0 1/1 * ? ")
public void send() {
rocketMQTemplate.syncSendOrderly(orderTopic, "这是一条MQ消息", UUID.randomUUID().toString());
log.info("MQ发送消息成功");
}
接收消息
package agatha.pet.mq;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
/**
* @author oak
* @date 2021/1/11
*/
@Slf4j
@Component
@RocketMQMessageListener(consumerGroup = "pet_group", topic = "${pet.topic.order}")
public class OrderConsumer implements RocketMQListener
上一篇:结构体字符串排序
下一篇:javaScript事件流
文章标题:RocketMQ下载、安装、以及结合Springboot的使用
文章链接:http://soscw.com/index.php/essay/61427.html