发送消息到mq
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user