发送消息到mq
This commit is contained in:
@@ -1,20 +1,25 @@
|
|||||||
package com.tongran.agenttcp.server.enpoint;
|
package com.tongran.agenttcp.server.enpoint;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
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.annotation.AgentDispatcher;
|
||||||
import com.tongran.agenttcp.server.basics.AgentMsgHandler;
|
import com.tongran.agenttcp.server.basics.AgentMsgHandler;
|
||||||
import com.tongran.agenttcp.server.model.UpMsgResponse;
|
import com.tongran.agenttcp.server.model.UpMsgResponse;
|
||||||
import com.tongran.agenttcp.server.netty.enums.MsgEnum;
|
import com.tongran.agenttcp.server.netty.enums.MsgEnum;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AgentEndpoint {
|
public class AgentEndpoint {
|
||||||
|
|
||||||
// @Resource
|
@Resource
|
||||||
// private AgentMqConfig agentMqConfig;
|
private AgentMqConfig agentMqConfig;
|
||||||
//
|
|
||||||
// @Resource
|
@Resource
|
||||||
// private AgentProducer agentProducer;
|
private AgentProducer agentProducer;
|
||||||
|
|
||||||
@AgentDispatcher(msgId = MsgEnum.登录认证)
|
@AgentDispatcher(msgId = MsgEnum.登录认证)
|
||||||
public class LoginHandler implements AgentMsgHandler {
|
public class LoginHandler implements AgentMsgHandler {
|
||||||
@@ -22,8 +27,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
// MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
// agentProducer.asyncSend(mqMsg);
|
agentProducer.asyncSend(mqMsg);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("resCode",1);
|
json.put("resCode",1);
|
||||||
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
||||||
@@ -57,8 +62,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
// MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
// agentProducer.asyncSend(mqMsg);
|
agentProducer.asyncSend(mqMsg);
|
||||||
|
|
||||||
// T0x04 obj = new T0x04();
|
// T0x04 obj = new T0x04();
|
||||||
// StringBuilder res = new StringBuilder();
|
// StringBuilder res = new StringBuilder();
|
||||||
@@ -109,6 +114,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
|
agentProducer.asyncSend(mqMsg);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("resCode",1);
|
json.put("resCode",1);
|
||||||
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
||||||
@@ -131,6 +138,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
|
agentProducer.asyncSend(mqMsg);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("resCode",1);
|
json.put("resCode",1);
|
||||||
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
||||||
@@ -153,6 +162,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
|
agentProducer.asyncSend(mqMsg);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("resCode",1);
|
json.put("resCode",1);
|
||||||
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
||||||
@@ -175,6 +186,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
|
agentProducer.asyncSend(mqMsg);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("resCode",1);
|
json.put("resCode",1);
|
||||||
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
||||||
@@ -197,6 +210,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
|
agentProducer.asyncSend(mqMsg);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("resCode",1);
|
json.put("resCode",1);
|
||||||
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
||||||
@@ -219,6 +234,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
|
agentProducer.asyncSend(mqMsg);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("resCode",1);
|
json.put("resCode",1);
|
||||||
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
||||||
@@ -241,6 +258,8 @@ public class AgentEndpoint {
|
|||||||
public UpMsgResponse upHandle(String data) {
|
public UpMsgResponse upHandle(String data) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String clientId = jsonObject.getString("clientId");
|
String clientId = jsonObject.getString("clientId");
|
||||||
|
MqMsg mqMsg = MqMsg.builder().topic(agentMqConfig.getAgentTopic()).content(data).build();
|
||||||
|
agentProducer.asyncSend(mqMsg);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("resCode",1);
|
json.put("resCode",1);
|
||||||
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
return UpMsgResponse.builder().clientId(clientId).content(json.toString()).build();
|
||||||
|
|||||||
Reference in New Issue
Block a user