From b00043a5df6bd6b4bd95e2ce35c92b871f2e99a7 Mon Sep 17 00:00:00 2001 From: Pascal Verdier Date: Tue, 12 Nov 2019 09:27:39 +0100 Subject: [PATCH] Do the connection whith HWM for send is set without limit to avoid problem due to the buffer size when connect to server for large number of attributes --- .../esrf/TangoApi/events/ZmqMainThread.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/dao/src/main/java/fr/esrf/TangoApi/events/ZmqMainThread.java b/dao/src/main/java/fr/esrf/TangoApi/events/ZmqMainThread.java index c7c1b195..99e53a38 100755 --- a/dao/src/main/java/fr/esrf/TangoApi/events/ZmqMainThread.java +++ b/dao/src/main/java/fr/esrf/TangoApi/events/ZmqMainThread.java @@ -70,13 +70,13 @@ public class ZmqMainThread extends Thread { private static final long SendHwmSocket = 10000; //=============================================================== - private class ZmqPollers extends ZMQ.Poller { + //=============================================================== + private static class ZmqPollers extends ZMQ.Poller { private ZmqPollers(ZMQ.Context context, int size) { super(context, size); } } //=============================================================== - //=============================================================== /** * Default constructor * @param context ZMQ context instance @@ -667,19 +667,20 @@ private void connectIfNotDone(ZMQ.Socket socket, ZMQutils.ControlStructure contr // Check if it ia a reconnection -> disconnect before connection if (controlStructure.forceReconnection && alreadyConnected(controlStructure.endPoint)) { try { - // needs an un subscribe before disconnection - //socket.unsubscribe(controlStructure.eventName.getBytes()); socket.disconnect(controlStructure.endPoint); } catch (org.zeromq.ZMQException e) { System.err.println(e.getMessage()); } } - - // Do the connection //System.out.println("Connect on " + controlStructure.endPoint); //System.out.println(" for " + controlStructure.eventName); - socket.setHWM(controlStructure.hwm); + + // Do the connection (HWM for send is set without limit + // to avoid problem due to the buffer size when connect + // to server for large number of attributes) + socket.setSndHWM(0); + socket.setRcvHWM(controlStructure.hwm); socket.connect(controlStructure.endPoint); if (!alreadyConnected(controlStructure.endPoint)) { EventList eventList = new EventList(); @@ -763,11 +764,9 @@ private static String formatTime(long ms) return time + "." + ms; } - - //=============================================================== //=============================================================== - private class EventList extends ArrayList { + private static class EventList extends ArrayList { private String getEvent(String eventName) { for (String event : this) { if (event.equals(eventName)) {