@Override protected void doStart() throws Exception { socketTransportStarted.countDown(); stompInactivityMonitor.setTransportListener(getTransportListener()); stompInactivityMonitor.startConnectCheckTask(); }
@Override protected boolean configuredOk() throws IOException { if (!isConfigured) { return false; } LOG.debug("Stomp Inactivity Monitor read check interval: {}ms, write check interval: {}ms", getReadCheckTime(), getWriteCheckTime()); return this.getReadCheckTime() >= 0 && this.getWriteCheckTime() >= 0; } }
public void startMonitoring() throws IOException { this.isConfigured = true; stopConnectCheckTask(); startMonitorThreads(); }
protected void configureInactivityMonitor(String heartBeatConfig) throws ProtocolException { String[] keepAliveOpts = heartBeatConfig.split(Stomp.COMMA); if (keepAliveOpts == null || keepAliveOpts.length != 2) { throw new ProtocolException("Invalid heart-beat header:" + heartBeatConfig, true); } else { try { hbReadInterval = (Long.parseLong(keepAliveOpts[0])); hbWriteInterval = Long.parseLong(keepAliveOpts[1]); } catch(NumberFormatException e) { throw new ProtocolException("Invalid heart-beat header:" + heartBeatConfig, true); } try { StompInactivityMonitor monitor = this.stompTransport.getInactivityMonitor(); monitor.setReadCheckTime((long) (hbReadInterval * hbGracePeriodMultiplier)); monitor.setInitialDelayTime(Math.min(hbReadInterval, hbWriteInterval)); monitor.setWriteCheckTime(hbWriteInterval); monitor.startMonitoring(); } catch(Exception ex) { hbReadInterval = 0; hbWriteInterval = 0; } if (LOG.isDebugEnabled()) { LOG.debug("Stomp Connect heartbeat conf RW[{},{}]", hbReadInterval, hbWriteInterval); } } }
@Override protected Transport createInactivityMonitor(Transport transport, WireFormat format) { StompInactivityMonitor monitor = new StompInactivityMonitor(transport, format); StompTransportFilter filter = (StompTransportFilter) transport.narrow(StompTransportFilter.class); filter.setInactivityMonitor(monitor); return monitor; } }
@Override public void start() throws Exception { if (monitor != null) { monitor.startConnectCheckTask(getConnectAttemptTimeout()); } super.start(); }
protected void processStompFrame(String data) { if (!transportStartedAtLeastOnce()) { LOG.debug("Waiting for StompSocket to be properly started..."); try { socketTransportStarted.await(); } catch (InterruptedException e) { LOG.warn("While waiting for StompSocket to be properly started, we got interrupted!! Should be okay, but you could see race conditions..."); } } protocolLock.lock(); try { if (data != null) { receiveCounter += data.length(); if (data.equals("\n")) { stompInactivityMonitor.onCommand(new KeepAliveInfo()); } else { StompFrame frame = (StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))); frame.setTransportContext(getPeerCertificates()); protocolConverter.onStompCommand(frame); } } } catch (Exception e) { onException(IOExceptionSupport.create(e)); } finally { protocolLock.unlock(); } }
protected void configureInactivityMonitor(String heartBeatConfig) throws ProtocolException { String[] keepAliveOpts = heartBeatConfig.split(Stomp.COMMA); if (keepAliveOpts == null || keepAliveOpts.length != 2) { throw new ProtocolException("Invalid heart-beat header:" + heartBeatConfig, true); } else { try { hbReadInterval = (Long.parseLong(keepAliveOpts[0])); hbWriteInterval = Long.parseLong(keepAliveOpts[1]); } catch(NumberFormatException e) { throw new ProtocolException("Invalid heart-beat header:" + heartBeatConfig, true); } try { StompInactivityMonitor monitor = this.stompTransport.getInactivityMonitor(); monitor.setReadCheckTime((long) (hbReadInterval * hbGracePeriodMultiplier)); monitor.setInitialDelayTime(Math.min(hbReadInterval, hbWriteInterval)); monitor.setWriteCheckTime(hbWriteInterval); monitor.startMonitoring(); } catch(Exception ex) { hbReadInterval = 0; hbWriteInterval = 0; } if (LOG.isDebugEnabled()) { LOG.debug("Stomp Connect heartbeat conf RW[{},{}]", hbReadInterval, hbWriteInterval); } } }
@Override protected Transport createInactivityMonitor(Transport transport, WireFormat format) { StompInactivityMonitor monitor = new StompInactivityMonitor(transport, format); StompTransportFilter filter = (StompTransportFilter) transport.narrow(StompTransportFilter.class); filter.setInactivityMonitor(monitor); return monitor; } }
@Override public void start() throws Exception { if (monitor != null) { monitor.startConnectCheckTask(getConnectAttemptTimeout()); } super.start(); }
protected void processStompFrame(String data) { if (!transportStartedAtLeastOnce()) { LOG.debug("Waiting for StompSocket to be properly started..."); try { socketTransportStarted.await(); } catch (InterruptedException e) { LOG.warn("While waiting for StompSocket to be properly started, we got interrupted!! Should be okay, but you could see race conditions..."); } } protocolLock.lock(); try { if (data != null) { receiveCounter += data.length(); if (data.equals("\n")) { stompInactivityMonitor.onCommand(new KeepAliveInfo()); } else { StompFrame frame = (StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))); frame.setTransportContext(getPeerCertificates()); protocolConverter.onStompCommand(frame); } } } catch (Exception e) { onException(IOExceptionSupport.create(e)); } finally { protocolLock.unlock(); } }
protected void configureInactivityMonitor(String heartBeatConfig) throws ProtocolException { String[] keepAliveOpts = heartBeatConfig.split(Stomp.COMMA); if (keepAliveOpts == null || keepAliveOpts.length != 2) { throw new ProtocolException("Invalid heart-beat header:" + heartBeatConfig, true); } else { try { hbReadInterval = (Long.parseLong(keepAliveOpts[0])); hbWriteInterval = Long.parseLong(keepAliveOpts[1]); } catch(NumberFormatException e) { throw new ProtocolException("Invalid heart-beat header:" + heartBeatConfig, true); } try { StompInactivityMonitor monitor = this.stompTransport.getInactivityMonitor(); monitor.setReadCheckTime((long) (hbReadInterval * hbGracePeriodMultiplier)); monitor.setInitialDelayTime(Math.min(hbReadInterval, hbWriteInterval)); monitor.setWriteCheckTime(hbWriteInterval); monitor.startMonitoring(); } catch(Exception ex) { hbReadInterval = 0; hbWriteInterval = 0; } if (LOG.isDebugEnabled()) { LOG.debug("Stomp Connect heartbeat conf RW[{},{}]", hbReadInterval, hbWriteInterval); } } }
@Override protected void doStart() throws Exception { socketTransportStarted.countDown(); stompInactivityMonitor.setTransportListener(getTransportListener()); stompInactivityMonitor.startConnectCheckTask(); }
@Override protected boolean configuredOk() throws IOException { if (!isConfigured) { return false; } LOG.debug("Stomp Inactivity Monitor read check interval: {}ms, write check interval: {}ms", getReadCheckTime(), getWriteCheckTime()); return this.getReadCheckTime() >= 0 && this.getWriteCheckTime() >= 0; } }
public void startMonitoring() throws IOException { this.isConfigured = true; stopConnectCheckTask(); startMonitorThreads(); }
@Override protected Transport createInactivityMonitor(Transport transport, WireFormat format) { StompInactivityMonitor monitor = new StompInactivityMonitor(transport, format); StompTransportFilter filter = (StompTransportFilter) transport.narrow(StompTransportFilter.class); filter.setInactivityMonitor(monitor); return monitor; } }
@Override public void start() throws Exception { if (monitor != null) { monitor.startConnectCheckTask(getConnectAttemptTimeout()); } super.start(); }
protected void processStompFrame(String data) { if (!transportStartedAtLeastOnce()) { LOG.debug("Waiting for StompSocket to be properly started..."); try { socketTransportStarted.await(); } catch (InterruptedException e) { LOG.warn("While waiting for StompSocket to be properly started, we got interrupted!! Should be okay, but you could see race conditions..."); } } protocolLock.lock(); try { if (data != null) { receiveCounter += data.length(); if (data.equals("\n")) { stompInactivityMonitor.onCommand(new KeepAliveInfo()); } else { StompFrame frame = (StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))); frame.setTransportContext(getPeerCertificates()); protocolConverter.onStompCommand(frame); } } } catch (Exception e) { onException(IOExceptionSupport.create(e)); } finally { protocolLock.unlock(); } }
@Override protected void doStart() throws Exception { socketTransportStarted.countDown(); stompInactivityMonitor.setTransportListener(getTransportListener()); stompInactivityMonitor.startConnectCheckTask(); }
@Override protected boolean configuredOk() throws IOException { if (!isConfigured) { return false; } LOG.debug("Stomp Inactivity Monitor read check interval: {}ms, write check interval: {}ms", getReadCheckTime(), getWriteCheckTime()); return this.getReadCheckTime() >= 0 && this.getWriteCheckTime() >= 0; } }