From 915c265ef913601c2698faaa428f96f1e09a2369 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 27 六月 2025 17:00:38 +0800 Subject: [PATCH] 提交推送服务 --- /dev/null | 39 --------------------------------------- MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java | 1 - MessagePushTravel/src/main/java/com/sinata/push/MessagePushApplication.java | 2 -- MessagePushTravel/src/main/resources/application.yml | 4 ++-- 4 files changed, 2 insertions(+), 44 deletions(-) diff --git a/MessagePushTravel/src/main/java/com/sinata/push/MessagePushApplication.java b/MessagePushTravel/src/main/java/com/sinata/push/MessagePushApplication.java index a4b1862..72d20b1 100644 --- a/MessagePushTravel/src/main/java/com/sinata/push/MessagePushApplication.java +++ b/MessagePushTravel/src/main/java/com/sinata/push/MessagePushApplication.java @@ -4,10 +4,8 @@ import com.sinata.push.util.echo.NettyServer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableScheduling; -@EnableScheduling//开启定时任务 @SpringBootApplication public class MessagePushApplication { diff --git a/MessagePushTravel/src/main/java/com/sinata/push/util/TaskUtil.java b/MessagePushTravel/src/main/java/com/sinata/push/util/TaskUtil.java deleted file mode 100644 index d6ab008..0000000 --- a/MessagePushTravel/src/main/java/com/sinata/push/util/TaskUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinata.push.util; - -import com.sinata.push.util.echo.Method; -import com.sinata.push.util.echo.NettyChannelMap; -import com.sinata.push.util.echo.NettyMsg; -import io.netty.buffer.Unpooled; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandlerContext; -import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.util.HashMap; - -/** - * @author zhibing.pu - * @Date 2025/6/25 20:33 - */ -@Slf4j -@Component -public class TaskUtil { - - - @Scheduled(fixedRate = 1000) - public void taskMinute(){ - NettyChannelMap.map.keySet().forEach(key -> { - ChannelHandlerContext context = NettyChannelMap.map.get(key); - Channel channel = context.channel(); - if(context != null && channel.isActive()){ - String s = NettyMsg.setMsg(Method.ok, new HashMap<String, Object>()); - context.writeAndFlush(Unpooled.copiedBuffer((s).getBytes())); - log.info("send channel:{}", key); - }else{ - NettyChannelMap.map.remove(key); - log.info("remove channel:{}", key); - } - }); - } -} diff --git a/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java b/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java index 014705c..1645378 100644 --- a/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java +++ b/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java @@ -228,7 +228,6 @@ System.err.println("调用driver-server存储位置数据出错了"); } } - System.out.println("id:" + driverId + "---lon" + lon + "---lat" + lat); redisTemplate.opsForValue().set("DRIVER" + driverId, lon + "," + lat, 300, TimeUnit.SECONDS);//实时位置存入redis中 }else{ this.sendMsgToClient(ctx, "__error__" + msg.toString()); diff --git a/MessagePushTravel/src/main/resources/application.yml b/MessagePushTravel/src/main/resources/application.yml index e3f3db1..7248f91 100644 --- a/MessagePushTravel/src/main/resources/application.yml +++ b/MessagePushTravel/src/main/resources/application.yml @@ -2,8 +2,8 @@ port: 6000 spring: profiles: - active: dev -# active: prod +# active: dev + active: prod application: name: message #服务名称 servlet: -- Gitblit v1.7.1