From e2c2b626653c879e2b395eba3e0982c5d81fe788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E6=98=BE=E4=BC=98?= <237809796@qq.com> Date: Mon, 17 Apr 2023 02:11:07 +0800 Subject: [PATCH] . --- src/main/java/tccn/zhub/ZHubClient.java | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/tccn/zhub/ZHubClient.java b/src/main/java/tccn/zhub/ZHubClient.java index 99c226a..b8600e8 100644 --- a/src/main/java/tccn/zhub/ZHubClient.java +++ b/src/main/java/tccn/zhub/ZHubClient.java @@ -298,24 +298,26 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer // send msg new Thread(() -> { - String msg = null; - try { - msg = sendMsgQueue.take(); - writer.write(msg.getBytes(UTF_8)); - writer.flush(); - } catch (InterruptedException | IOException e) { - logger.log(Level.WARNING, "send-msg[" + msg + "] event accept error :", e); - + while (true) { + String msg = null; try { - Thread.sleep(3000); - assert msg != null; + msg = sendMsgQueue.take(); writer.write(msg.getBytes(UTF_8)); writer.flush(); - } catch (IOException | InterruptedException | NullPointerException ex) { - e.printStackTrace(); + } catch (InterruptedException | IOException e) { + logger.log(Level.WARNING, "send-msg[" + msg + "] event accept error :", e); + + try { + Thread.sleep(3000); + assert msg != null; + writer.write(msg.getBytes(UTF_8)); + writer.flush(); + } catch (IOException | InterruptedException | NullPointerException ex) { + e.printStackTrace(); + } } } - }); + }).start(); }