mirror of
https://github.com/201206030/novel-cloud.git
synced 2025-06-25 06:26:39 +00:00
引入rabbitmq/应用解偶/流量削峰,引入redisson实现分布式锁
This commit is contained in:
@ -48,6 +48,12 @@
|
||||
<artifactId>spring-boot-starter-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
<version>${redisson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
@ -105,6 +111,11 @@
|
||||
<artifactId>feign-httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
@ -0,0 +1,62 @@
|
||||
package com.java2nb.novel.common.config;
|
||||
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.FanoutExchange;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author 11797
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host", matchIfMissing = false)
|
||||
public class RabbitConfig {
|
||||
|
||||
|
||||
/**
|
||||
* 更新数据库队列
|
||||
*/
|
||||
@Bean
|
||||
public Queue updateDbQueue() {
|
||||
return new Queue("UPDATE-DB-QUEUE", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据库队列
|
||||
*/
|
||||
@Bean
|
||||
public Queue updateEsQueue() {
|
||||
return new Queue("UPDATE-ES-QUEUE", true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 增加点击量交换机
|
||||
*/
|
||||
@Bean
|
||||
public FanoutExchange addVisitExchange() {
|
||||
return new FanoutExchange("ADD-BOOK-VISIT-EXCHANGE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新搜索引擎队列绑定到增加点击量交换机中
|
||||
*/
|
||||
@Bean
|
||||
public Binding updateEsBinding() {
|
||||
|
||||
return BindingBuilder.bind(updateEsQueue()).to(addVisitExchange());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据库绑定到增加点击量交换机中
|
||||
*/
|
||||
@Bean
|
||||
public Binding updateDbBinding() {
|
||||
return BindingBuilder.bind(updateDbQueue()).to(addVisitExchange());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -19,6 +19,12 @@ feign:
|
||||
httpclient:
|
||||
enabled: true
|
||||
|
||||
#关掉mq的健康检查,防止某些没有用到mq的服务启动报错,个别服务如需mq监控,单独开启
|
||||
management:
|
||||
health:
|
||||
rabbit:
|
||||
enabled: false
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user