1、修改TCP的重连机制,只有在发送数据时才connect
This commit is contained in:
parent
f68d548a2c
commit
40cee949a9
@ -99,7 +99,7 @@ public class TCPClient {
|
|||||||
public void writeAndFlush(String json) {
|
public void writeAndFlush(String json) {
|
||||||
ByteBuf sendBuffer = Unpooled.buffer();
|
ByteBuf sendBuffer = Unpooled.buffer();
|
||||||
sendBuffer.writeBytes(json.getBytes(StandardCharsets.UTF_8));
|
sendBuffer.writeBytes(json.getBytes(StandardCharsets.UTF_8));
|
||||||
logger.info("send to {}: {}",host,json);
|
//logger.info("send to {}: {}",host,json);
|
||||||
if(channel==null || !channel.isActive()){
|
if(channel==null || !channel.isActive()){
|
||||||
try {
|
try {
|
||||||
if(!tryReconnect()) return;
|
if(!tryReconnect()) return;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class GXJSForwarder extends GXXfzForwarder{
|
|||||||
/**
|
/**
|
||||||
* 每半小时转发GNSS解算结果
|
* 每半小时转发GNSS解算结果
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0/10 * * * ?") // 每30分钟执行一次
|
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
||||||
private void forwardGnss() {
|
private void forwardGnss() {
|
||||||
if(!enabled) return;
|
if(!enabled) return;
|
||||||
logger.debug("gxjs forwardGnss");
|
logger.debug("gxjs forwardGnss");
|
||||||
|
|||||||
@ -91,8 +91,8 @@ public class GXXfzForwarder extends Forwarder{
|
|||||||
|
|
||||||
if(batchNum>0){
|
if(batchNum>0){
|
||||||
String json = "#" + GsonUtil.toJson(xfzTcpMessage) + "!";
|
String json = "#" + GsonUtil.toJson(xfzTcpMessage) + "!";
|
||||||
//logger.debug("project {}: forwad {} gnss records to {}",projectId, dataList.size(),fwdGroupId);
|
logger.debug("project {}: forwad {} gnss records to {}",projectId, dataList.size(),fwdGroupId);
|
||||||
//logger.debug(json);
|
logger.debug(json);
|
||||||
try {
|
try {
|
||||||
listener.clear();
|
listener.clear();
|
||||||
xfzTcpClient.writeAndFlush(json);
|
xfzTcpClient.writeAndFlush(json);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user