parent
b78c005476
commit
86e6d4df2c
@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.mashibing</groupId>
|
||||||
|
<artifactId>beacon-cloud</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>beacon-push</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- web -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- nacos注册中心 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- nacos配置中心 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- AMQP -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 测试 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- lombok -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- common公共组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mashibing</groupId>
|
||||||
|
<artifactId>beacon-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.mashibing.push;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: PushApplication
|
||||||
|
* @Description: 推送模块启动类
|
||||||
|
* @date 2025/6/12 19:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableFeignClients
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
public class PushApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(PushApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.mashibing.push.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.core.*;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: RabbitMQConfig
|
||||||
|
* @Description: 声明延迟交换机并绑定队列
|
||||||
|
* @date 2025/6/12 21:35
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RabbitMQConfig {
|
||||||
|
|
||||||
|
public static final String DELAYED_EXCHANGE = "push_delayed_exchange";
|
||||||
|
|
||||||
|
public static final String DELAYED_QUEUE = "push_delayed_queue";
|
||||||
|
|
||||||
|
private static final String DELAYED_EXCHANGE_TYPE = "x-delayed-message";
|
||||||
|
|
||||||
|
private static final String DELAYED_ROUTING_TYPE_KEY = "x-delayed-type";
|
||||||
|
|
||||||
|
private static final String DELAYED_ROUTING_TYPE_FANOUT = "fanout";
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Exchange delayedExchange() {
|
||||||
|
Map<String, Object> args = new HashMap<String, Object>();
|
||||||
|
args.put(DELAYED_ROUTING_TYPE_KEY, DELAYED_ROUTING_TYPE_FANOUT);
|
||||||
|
return new CustomExchange(DELAYED_EXCHANGE, DELAYED_EXCHANGE_TYPE, true, false, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue delayedQueue() {
|
||||||
|
return QueueBuilder.durable(DELAYED_QUEUE).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Binding delayedExchangeBinding(Exchange delayedExchange, Queue delayedQueue) {
|
||||||
|
return BindingBuilder.bind(delayedQueue).to(delayedExchange).with("").noargs();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.mashibing.push.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: RestTemplateConfig
|
||||||
|
* @Description: RestTemplateConfig配置类
|
||||||
|
* @date 2025/6/12 19:54
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.mashibing.push.feignclient;
|
||||||
|
|
||||||
|
import com.mashibing.common.clients.BeaconCacheClient;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: Cacheclient
|
||||||
|
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||||
|
* @date 2025/6/12 19:55
|
||||||
|
*/
|
||||||
|
|
||||||
|
@FeignClient("beacon-cache")
|
||||||
|
public interface Cacheclient extends BeaconCacheClient {
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
# 服务名称
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: beacon-push
|
||||||
|
# 多环境
|
||||||
|
profiles:
|
||||||
|
active: dev
|
||||||
|
# nacos注册中心地址
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: 192.168.1.13:8848
|
||||||
|
# nacos配置中心地址:
|
||||||
|
config:
|
||||||
|
server-addr: 192.168.1.13:8848
|
||||||
|
file-extension: yml
|
||||||
|
# beacon-push-dev.yml
|
Loading…
Reference in new issue