Commit d0647d17 authored by 杨锐's avatar 杨锐

zipkin一致性追踪

parent c77d9b40
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<version>0.2.5.3</version> <version>0.2.6-SNAPSHOT</version>
</parent> </parent>
<artifactId>xyqb-user2</artifactId> <artifactId>xyqb-user2</artifactId>
......
package cn.quantgroup.xyqb.config.event; package cn.quantgroup.xyqb.config.event;
import cn.quantgroup.tech.brave.service.ITechExecutorServiceBuilder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -8,6 +9,7 @@ import org.springframework.context.event.SimpleApplicationEventMulticaster; ...@@ -8,6 +9,7 @@ import org.springframework.context.event.SimpleApplicationEventMulticaster;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.support.TaskUtils; import org.springframework.scheduling.support.TaskUtils;
import javax.annotation.Resource;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
...@@ -16,6 +18,9 @@ import java.util.concurrent.ThreadPoolExecutor; ...@@ -16,6 +18,9 @@ import java.util.concurrent.ThreadPoolExecutor;
@Configuration @Configuration
public class EventConfig { public class EventConfig {
@Resource
private ITechExecutorServiceBuilder techExecutorServiceBuilder;
@Bean @Bean
public ApplicationEventMulticaster applicationEventMulticaster(Executor taskExecutor) { public ApplicationEventMulticaster applicationEventMulticaster(Executor taskExecutor) {
SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new SimpleApplicationEventMulticaster(); SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new SimpleApplicationEventMulticaster();
...@@ -35,7 +40,7 @@ public class EventConfig { ...@@ -35,7 +40,7 @@ public class EventConfig {
poolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true); poolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
poolTaskExecutor.setRejectedExecutionHandler(new RejectedHandler()); poolTaskExecutor.setRejectedExecutionHandler(new RejectedHandler());
poolTaskExecutor.initialize(); poolTaskExecutor.initialize();
return poolTaskExecutor; return techExecutorServiceBuilder.buildExecutorService(poolTaskExecutor.getThreadPoolExecutor());
} }
public static class RejectedHandler implements RejectedExecutionHandler { public static class RejectedHandler implements RejectedExecutionHandler {
......
...@@ -26,13 +26,13 @@ public class PhoneHashEventListener implements ApplicationListener<RegisterEvent ...@@ -26,13 +26,13 @@ public class PhoneHashEventListener implements ApplicationListener<RegisterEvent
@Override @Override
public void onApplicationEvent(RegisterEvent event) { public void onApplicationEvent(RegisterEvent event) {
log.info("onApplicationEvent cn.quantgroup.xyqb.event.PhoneHashEventListener start");
UserRegisterParam userRegisterParam = event.getUserRegisterParam(); UserRegisterParam userRegisterParam = event.getUserRegisterParam();
String phoneNo = userRegisterParam.getPhoneNo(); String phoneNo = userRegisterParam.getPhoneNo();
Long userId = userRegisterParam.getUser().getId(); Long userId = userRegisterParam.getUser().getId();
String idNo = userRegisterParam.getIdNo(); String idNo = userRegisterParam.getIdNo();
/* modify by yangrui on 2019/12/16 下午5:47 */
UserHashPhoneNoIdNoMapping userHashPhoneNoIdNoMapping = userHashPhoneNoIdNoMappingRepository.findByUserId(userId); UserHashPhoneNoIdNoMapping userHashPhoneNoIdNoMapping = userHashPhoneNoIdNoMappingRepository.findByUserId(userId);
if (userHashPhoneNoIdNoMapping == null) { if (userHashPhoneNoIdNoMapping == null) {
userHashPhoneNoIdNoMapping = new UserHashPhoneNoIdNoMapping(userId); userHashPhoneNoIdNoMapping = new UserHashPhoneNoIdNoMapping(userId);
......
...@@ -29,6 +29,7 @@ public class UserDetailHashEventListener implements ApplicationListener<UserDeta ...@@ -29,6 +29,7 @@ public class UserDetailHashEventListener implements ApplicationListener<UserDeta
@Override @Override
public void onApplicationEvent(UserDetailUpdateEvent event) { public void onApplicationEvent(UserDetailUpdateEvent event) {
log.info("onApplicationEvent cn.quantgroup.xyqb.event.UserDetailHashEventListener start");
UserDetail userDetail = event.getUserDetail(); UserDetail userDetail = event.getUserDetail();
UserHashMapping userHashMapping = userHashMappingRepository.findByUserId(userDetail.getUserId()); UserHashMapping userHashMapping = userHashMappingRepository.findByUserId(userDetail.getUserId());
...@@ -51,7 +52,6 @@ public class UserDetailHashEventListener implements ApplicationListener<UserDeta ...@@ -51,7 +52,6 @@ public class UserDetailHashEventListener implements ApplicationListener<UserDeta
log.error("保存userHashMapping重复, 无需再保存, userId:{}", userDetail.getUserId()); log.error("保存userHashMapping重复, 无需再保存, userId:{}", userDetail.getUserId());
} }
/* modify by yangrui on 2019/12/16 下午5:48 */
UserHashPhoneNoIdNoMapping userHashPhoneNoIdNoMapping = userHashPhoneNoIdNoMappingRepository.findByUserId(userDetail.getUserId()); UserHashPhoneNoIdNoMapping userHashPhoneNoIdNoMapping = userHashPhoneNoIdNoMappingRepository.findByUserId(userDetail.getUserId());
//如果不存在, 我先保存一下 //如果不存在, 我先保存一下
......
...@@ -3,12 +3,14 @@ package cn.quantgroup.xyqb.event; ...@@ -3,12 +3,14 @@ package cn.quantgroup.xyqb.event;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.WechatUserInfo; import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.service.wechat.IWechatService; import cn.quantgroup.xyqb.service.wechat.IWechatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Objects; import java.util.Objects;
@Slf4j
@Component @Component
public class WechatPhoneNoUpdateEventListener implements ApplicationListener<PhoneNoUpdateEvent> { public class WechatPhoneNoUpdateEventListener implements ApplicationListener<PhoneNoUpdateEvent> {
...@@ -17,6 +19,7 @@ public class WechatPhoneNoUpdateEventListener implements ApplicationListener<Pho ...@@ -17,6 +19,7 @@ public class WechatPhoneNoUpdateEventListener implements ApplicationListener<Pho
@Override @Override
public void onApplicationEvent(PhoneNoUpdateEvent event) { public void onApplicationEvent(PhoneNoUpdateEvent event) {
log.info("onApplicationEvent cn.quantgroup.xyqb.event.WechatPhoneNoUpdateEventListener start");
String oldPhoneNo = event.getOldPhoneNo(); String oldPhoneNo = event.getOldPhoneNo();
User user = event.getUser(); User user = event.getUser();
WechatUserInfo userInfo = wechatService.findWechatUserInfoByPhoneNo(oldPhoneNo); WechatUserInfo userInfo = wechatService.findWechatUserInfoByPhoneNo(oldPhoneNo);
......
...@@ -203,7 +203,6 @@ public class UserServiceImpl implements IUserService { ...@@ -203,7 +203,6 @@ public class UserServiceImpl implements IUserService {
md5Value = md5Value.toLowerCase(); md5Value = md5Value.toLowerCase();
long value = HashUtil.crc32(md5Value); long value = HashUtil.crc32(md5Value);
UserHashMapping userHashMapping; UserHashMapping userHashMapping;
/* modify by yangrui on 2019/12/13 上午11:52 */
if (FindByMd5Enum.PHONENO.getType() == type) { if (FindByMd5Enum.PHONENO.getType() == type) {
userHashMapping = userHashMappingRepository.findByPhoneNoMd5ShortAndPhoneNoMd5(value, md5Value); userHashMapping = userHashMappingRepository.findByPhoneNoMd5ShortAndPhoneNoMd5(value, md5Value);
} else if (FindByMd5Enum.IDNO.getType() == type) { } else if (FindByMd5Enum.IDNO.getType() == type) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment