From 6c80850516334b7db20bf10270b2935bb5560ce9 Mon Sep 17 00:00:00 2001 From: qiminbao Date: Thu, 21 Aug 2025 10:57:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E5=88=B0mq?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/enpoint/AgentEndpoint.java | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/tongran/agenttcp/server/enpoint/AgentEndpoint.java b/src/main/java/com/tongran/agenttcp/server/enpoint/AgentEndpoint.java index 907ad52..1bcc53b 100644 --- a/src/main/java/com/tongran/agenttcp/server/enpoint/AgentEndpoint.java +++ b/src/main/java/com/tongran/agenttcp/server/enpoint/AgentEndpoint.java @@ -1,20 +1,25 @@ package com.tongran.agenttcp.server.enpoint; import com.alibaba.fastjson2.JSONObject; +import com.tongran.agenttcp.rocketmq.AgentProducer; +import com.tongran.agenttcp.rocketmq.config.AgentMqConfig; +import com.tongran.agenttcp.rocketmq.core.model.MqMsg; import com.tongran.agenttcp.server.annotation.AgentDispatcher; import com.tongran.agenttcp.server.basics.AgentMsgHandler; import com.tongran.agenttcp.server.model.UpMsgResponse; import com.tongran.agenttcp.server.netty.enums.MsgEnum; import org.springframework.stereotype.Component; +import javax.annotation.Resource; + @Component public class AgentEndpoint { -// @Resource -// private AgentMqConfig agentMqConfig; -// -// @Resource -// private AgentProducer agentProducer; + @Resource + private AgentMqConfig agentMqConfig; + + @Resource + private AgentProducer agentProducer; @AgentDispatcher(msgId = MsgEnum.登录认证) public class LoginHandler implements AgentMsgHandler { @@ -22,8 +27,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); -// MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); -// agentProducer.asyncSend(mqMsg); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); JSONObject json = new JSONObject(); json.put("resCode",1); return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build(); @@ -57,8 +62,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); -// MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); -// agentProducer.asyncSend(mqMsg); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); // T0x04 obj = new T0x04(); // StringBuilder res = new StringBuilder(); @@ -109,6 +114,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); JSONObject json = new JSONObject(); json.put("resCode",1); return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build(); @@ -131,6 +138,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); JSONObject json = new JSONObject(); json.put("resCode",1); return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build(); @@ -153,6 +162,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); JSONObject json = new JSONObject(); json.put("resCode",1); return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build(); @@ -175,6 +186,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); JSONObject json = new JSONObject(); json.put("resCode",1); return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build(); @@ -197,6 +210,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); JSONObject json = new JSONObject(); json.put("resCode",1); return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build(); @@ -219,6 +234,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); JSONObject json = new JSONObject(); json.put("resCode",1); return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build(); @@ -241,6 +258,8 @@ public class AgentEndpoint { public UpMsgResponse upHandle(String data) { JSONObject jsonObject = JSONObject.parseObject(data); String clientId = jsonObject.getString("clientId"); + MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build(); + agentProducer.asyncSend(mqMsg); JSONObject json = new JSONObject(); json.put("resCode",1); return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();