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(); }