课程信息:
- 课程名称:RabbitMQ消息中间件极速入门与实战
- 章节名称:第三章 RabbitMQ-消息的可靠性投递-实现方案
- 讲师姓名:阿神
课程内容:
1. 增加新的依赖(与mybatis相关)
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper-spring-boot-starter</artifactId> <version>2.1.5</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.2.11</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/com.github.miemiedev/mybatis-paginator --> <dependency> <groupId>com.github.miemiedev</groupId> <artifactId>mybatis-paginator</artifactId> <version>1.2.15</version> <exclusions> <exclusion> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </exclusion> </exclusions> </dependency>
2. 编写application.properties
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.username=root spring.datasource.password=521lcc1314
3. 新建数据库表
此处贴上sql代码:
-- ---------------------------- -- Table structure for broker_message_log -- ---------------------------- DROP TABLE IF EXISTS `broker_message_log`; CREATE TABLE `broker_message_log` ( `message_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id主键', `message` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '消息内容', `try_count` int(10) UNSIGNED ZEROFILL NULL DEFAULT NULL COMMENT '重试次数', `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '消息投递状态 0 投递中 1 投递成功 2 投递失败', `creat_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `next_retry` datetime NULL DEFAULT NULL COMMENT '下一次重试时间或超时时间', `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', PRIMARY KEY (`message_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ---------------------------- -- Table structure for t_order -- ---------------------------- DROP TABLE IF EXISTS `t_order`; CREATE TABLE `t_order` ( `id` int NOT NULL, `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `message_id` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
4. 进行业务逻辑的开发
学习心得:
通过本次课程的学习我对于RabbitMQ有了一个比较全面的了解,学习了RabbitMQ的入门操作,以及RabbitMQ与SpringBoot的整合、RabbitMQ-消息的可靠性投递-实现方案等等知识,收获非常大,这是一门需要自己动手的课程,跟着老师思路敲代码会有不一样的收获。
课程截图: