mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-06 21:37:56 +08:00
[fix] 修复数据存乎导致主线程问题
This commit is contained in:
parent
7429cff23a
commit
f985cdac8f
@ -37,37 +37,42 @@ public class NettyClientSocketApplicationListener implements ApplicationListener
|
|||||||
*/
|
*/
|
||||||
public void initDb2Config() {
|
public void initDb2Config() {
|
||||||
|
|
||||||
String clientId = nettyClientProperties.getClientId();
|
try {
|
||||||
String inetHost = nettyClientProperties.getInetHost();
|
String clientId = nettyClientProperties.getClientId();
|
||||||
int inetPort = nettyClientProperties.getInetPort();
|
String inetHost = nettyClientProperties.getInetHost();
|
||||||
String appKey = nettyClientProperties.getAppKey();
|
int inetPort = nettyClientProperties.getInetPort();
|
||||||
String appSecret = nettyClientProperties.getAppSecret();
|
String appKey = nettyClientProperties.getAppKey();
|
||||||
ProtocolType protocolType = nettyClientProperties.getProtocolType();
|
String appSecret = nettyClientProperties.getAppSecret();
|
||||||
if (Objects.isNull(clientId) ||
|
ProtocolType protocolType = nettyClientProperties.getProtocolType();
|
||||||
Objects.isNull(inetHost)) {
|
if (Objects.isNull(clientId) ||
|
||||||
log.warn("配置信息为空,请通过页面添加配置信息:{}", nettyClientProperties);
|
Objects.isNull(inetHost)) {
|
||||||
return;
|
log.warn("配置信息为空,请通过页面添加配置信息:{}", nettyClientProperties);
|
||||||
}
|
return;
|
||||||
LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO = new LazyNettyServerPropertiesDO();
|
}
|
||||||
lazyNettyServerPropertiesDO.setClientId(clientId);
|
LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO = new LazyNettyServerPropertiesDO();
|
||||||
lazyNettyServerPropertiesDO.setInetHost(inetHost);
|
lazyNettyServerPropertiesDO.setClientId(clientId);
|
||||||
lazyNettyServerPropertiesDO.setInetPort(inetPort);
|
lazyNettyServerPropertiesDO.setInetHost(inetHost);
|
||||||
lazyNettyServerPropertiesDO.setType(PropertiesType.CONFIG);
|
lazyNettyServerPropertiesDO.setInetPort(inetPort);
|
||||||
lazyNettyServerPropertiesDO.setIsDeleted(false);
|
lazyNettyServerPropertiesDO.setType(PropertiesType.CONFIG);
|
||||||
lazyNettyServerPropertiesDO.setAppKey(appKey);
|
lazyNettyServerPropertiesDO.setIsDeleted(false);
|
||||||
lazyNettyServerPropertiesDO.setAppSecret(appSecret);
|
lazyNettyServerPropertiesDO.setAppKey(appKey);
|
||||||
lazyNettyServerPropertiesDO.setProtocolType(protocolType);
|
lazyNettyServerPropertiesDO.setAppSecret(appSecret);
|
||||||
|
lazyNettyServerPropertiesDO.setProtocolType(protocolType);
|
||||||
|
|
||||||
// 根据服务端端口、port 唯一性验证
|
|
||||||
boolean exists = lazyLambdaStream.exists(LazyWrappers.<LazyNettyServerPropertiesDO>lambdaWrapper()
|
// 根据服务端端口、port 唯一性验证
|
||||||
.eq(LazyNettyServerPropertiesDO::getInetHost, inetHost)
|
boolean exists = lazyLambdaStream.exists(LazyWrappers.<LazyNettyServerPropertiesDO>lambdaWrapper()
|
||||||
.eq(LazyNettyServerPropertiesDO::getInetPort, inetPort)
|
.eq(LazyNettyServerPropertiesDO::getInetHost, inetHost)
|
||||||
.eq(LazyNettyServerPropertiesDO::getClientId, clientId)
|
.eq(LazyNettyServerPropertiesDO::getInetPort, inetPort)
|
||||||
.eq(LazyNettyServerPropertiesDO::getProtocolType, protocolType)
|
.eq(LazyNettyServerPropertiesDO::getClientId, clientId)
|
||||||
);
|
.eq(LazyNettyServerPropertiesDO::getProtocolType, protocolType)
|
||||||
if (!exists) {
|
);
|
||||||
lazyLambdaStream.insert(lazyNettyServerPropertiesDO);
|
if (!exists) {
|
||||||
}
|
lazyLambdaStream.insert(lazyNettyServerPropertiesDO);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
//import io.netty.bootstrap.Bootstrap;
|
||||||
|
//import io.netty.channel.Channel;
|
||||||
|
//import io.netty.channel.ChannelOption;
|
||||||
|
//import io.netty.channel.EventLoopGroup;
|
||||||
|
//import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
|
//import io.netty.channel.socket.DatagramPacket;
|
||||||
|
//import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||||
|
//import io.netty.channel.socket.nio.NioMulticastChannel;
|
||||||
|
//
|
||||||
|
//import java.net.InetSocketAddress;
|
||||||
|
//
|
||||||
|
//public class NettyMulticastExample {
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) throws Exception {
|
||||||
|
// EventLoopGroup group = new NioEventLoopGroup();
|
||||||
|
// try {
|
||||||
|
// Bootstrap b = new Bootstrap();
|
||||||
|
// b.group(group)
|
||||||
|
// .channel(NioMulticastChannel.class)
|
||||||
|
// .option(ChannelOption.SO_BROADCAST, true)
|
||||||
|
// .handler(new MulticastChannelHandler());
|
||||||
|
//
|
||||||
|
// // 替换为你的虚拟IP和端口
|
||||||
|
// String multicastAddress = "230.0.0.1";
|
||||||
|
// int port = 30000;
|
||||||
|
// Channel ch = b.bind(new InetSocketAddress(multicastAddress, port)).sync().channel();
|
||||||
|
//
|
||||||
|
// // 发送数据
|
||||||
|
// ch.writeAndFlush(new DatagramPacket(
|
||||||
|
// Unpooled.copiedBuffer("Hello, world!", CharsetUtil.UTF_8),
|
||||||
|
// new InetSocketAddress(multicastAddress, port)));
|
||||||
|
//
|
||||||
|
// // 等待输入以关闭服务
|
||||||
|
// System.in.read();
|
||||||
|
// } finally {
|
||||||
|
// group.shutdownGracefully().sync();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static class MulticastChannelHandler extends ChannelInboundHandlerAdapter {
|
||||||
|
// @Override
|
||||||
|
// public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||||
|
// DatagramPacket packet = (DatagramPacket) msg;
|
||||||
|
// ByteBuf data = packet.content();
|
||||||
|
// System.out.println("Received message: " + data.toString(CharsetUtil.UTF_8));
|
||||||
|
// data.release();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||||
|
// cause.printStackTrace();
|
||||||
|
// ctx.close();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
Loading…
x
Reference in New Issue
Block a user