parent
ce800117f6
commit
88c562607a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,26 @@
|
||||
package com.mashibing.common.exception;
|
||||
|
||||
import com.mashibing.common.enums.ExceptionEnums;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author dch
|
||||
* @create 2024-03-20 12:15
|
||||
*/
|
||||
@Getter
|
||||
public class SearchException extends RuntimeException {
|
||||
|
||||
private Integer code;
|
||||
|
||||
public SearchException(String message, Integer code) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
public SearchException(ExceptionEnums enums) {
|
||||
super(enums.getMsg());
|
||||
this.code = enums.getCode();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.mashibing.push;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* @author dch
|
||||
* @create 2024-03-25 23:59
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class PushStarterApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PushStarterApp.class,args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
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 dch
|
||||
* @create 2024-03-26 1:00
|
||||
*/
|
||||
@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<>();
|
||||
//延迟交换机的路由类型----fanout
|
||||
args.put(DELAYED_ROUTING_TYPE_KEY,DELAYED_ROUTING_TYPE_FANOUT);
|
||||
Exchange delayedExchange = new CustomExchange(DELAYED_EXCHANGE,DELAYED_EXCHANGE_TYPE,false,false,args);
|
||||
return delayedExchange;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue delayedQueue(){
|
||||
return QueueBuilder.durable(DELAYED_QUEUE).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding delayedBinding(Exchange delayedExchange, Queue delayedQueue){
|
||||
return BindingBuilder.bind(delayedQueue).to(delayedExchange).with("").noargs();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.mashibing.push.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* @author dch
|
||||
* @create 2024-03-26 0:07
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
# 服务名称
|
||||
spring:
|
||||
application:
|
||||
name: beacon-push
|
||||
# 多环境
|
||||
profiles:
|
||||
active: dev
|
||||
# nacos注册中心地址
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.43.132:8848
|
||||
# nacos配置中心地址:
|
||||
config:
|
||||
server-addr: 192.168.43.132:8848
|
||||
file-extension: yml
|
||||
# beacon-push-dev.yml
|
@ -0,0 +1,18 @@
|
||||
package com.mashibing.search;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* @author dch
|
||||
* @create 2024-03-25 20:43
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class SearchStarterApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SearchStarterApp.class,args);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.mashibing.search.service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author dch
|
||||
* @create 2024-03-25 21:34
|
||||
*/
|
||||
public interface SearchService {
|
||||
/**
|
||||
* 向ES中添加一行文档
|
||||
*
|
||||
* @param index 索引信息
|
||||
* @param id 文档id
|
||||
* @param json 具体的文档内容
|
||||
*/
|
||||
void index(String index, String id, String json) throws IOException;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
# 服务名称
|
||||
spring:
|
||||
application:
|
||||
name: beacon-search
|
||||
# 多环境
|
||||
profiles:
|
||||
active: dev
|
||||
# nacos注册中心地址
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.43.132:8848
|
||||
# nacos配置中心地址:
|
||||
config:
|
||||
server-addr: 192.168.43.132:8848
|
||||
file-extension: yml
|
||||
# beacon-search-dev.yml
|
@ -0,0 +1,28 @@
|
||||
package com.mashibing.search.service;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author dch
|
||||
* @create 2024-03-25 21:49
|
||||
*/
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
public class SearchServiceTest {
|
||||
|
||||
@Autowired
|
||||
private SearchService searchService;
|
||||
|
||||
@Test
|
||||
public void index() throws IOException {
|
||||
searchService.index("sms_submit_log_2024","1","{\"clientId\":1}");
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.mashibing.smsgateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* @author dch
|
||||
* @create 2024-03-26 2:01
|
||||
*/
|
||||
@EnableDiscoveryClient
|
||||
@SpringBootApplication
|
||||
public class SmsGatewayStarterApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SmsGatewayStarterApp.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.mashibing.smsgateway.mq;
|
||||
|
||||
import com.mashibing.common.model.StandardSubmit;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author dch
|
||||
* @create 2024-03-26 2:12
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SmsGatewayListener {
|
||||
|
||||
@RabbitListener(queues = "${gateway.sendtopic}")
|
||||
public void consume(StandardSubmit submit, Channel channel, Message message) throws IOException, InterruptedException {
|
||||
log.info("【短信网关模块】 接收到消息 submit = {}", submit);
|
||||
// =====================完成运营商交互,发送一次请求,接收两次响应==========================
|
||||
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
# 服务名称
|
||||
spring:
|
||||
application:
|
||||
name: beacon-smsgateway
|
||||
# 多环境
|
||||
profiles:
|
||||
active: dev
|
||||
# nacos注册中心地址
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.43.132:8848
|
||||
# nacos配置中心地址:
|
||||
config:
|
||||
server-addr: 192.168.43.132:8848
|
||||
file-extension: yml
|
Loading…
Reference in new issue