Return-Path: X-Original-To: apmail-activemq-dev-archive@www.apache.org Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2B04F10DF0 for ; Wed, 4 Sep 2013 21:09:53 +0000 (UTC) Received: (qmail 52585 invoked by uid 500); 4 Sep 2013 21:09:52 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 52210 invoked by uid 500); 4 Sep 2013 21:09:52 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 51855 invoked by uid 99); 4 Sep 2013 21:09:52 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Sep 2013 21:09:52 +0000 Date: Wed, 4 Sep 2013 21:09:52 +0000 (UTC) From: "Paul Gale (JIRA)" To: dev@activemq.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AMQ-4710) The first heart-beat after a connection becomes idle isn't sent as quickly as it should be MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AMQ-4710?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:all-tabpanel ] Paul Gale updated AMQ-4710: --------------------------- Attachment: amq_4710.patch Patch file containing test and fix for this issue. =20 > The first heart-beat after a connection becomes idle isn't sent as quickl= y as it should be > -------------------------------------------------------------------------= ----------------- > > Key: AMQ-4710 > URL: https://issues.apache.org/jira/browse/AMQ-4710 > Project: ActiveMQ > Issue Type: Bug > Components: stomp > Affects Versions: 5.8.0 > Reporter: Andy Wilkinson > Attachments: amq_4710.patch > > > After ActiveMQ sends a stomp frame, it may not send a heart-beat for up t= o almost 2x the negotiated interval. > The following test should illustrate the problem: > {code} > import org.junit.Test; > import static org.junit.Assert.*; > public class ActiveMqHeartbeatTests { > =09@Test > =09public void heartbeats() throws Exception { > =09=09BrokerService broker =3D createAndStartBroker(); > =09=09Socket socket =3D null; > =09=09try { > =09=09=09socket =3D new Socket("localhost", 61613); > =09=09=09byte[] connectFrame =3D "CONNECT\nheart-beat:0,10000\naccept-ver= sion:1.2\n\n\0".getBytes(); > =09=09=09socket.getOutputStream().write(connectFrame); > =09=09=09byte[] buffer =3D new byte[4096]; > =09=09=09long lastReadTime =3D System.currentTimeMillis(); > =09=09=09while (true) { > =09=09=09=09int read =3D socket.getInputStream().read(buffer); > =09=09=09=09byte[] frame =3D Arrays.copyOf(buffer, read); > =09=09=09=09long now =3D System.currentTimeMillis(); > =09=09=09=09long timeSinceLastRead =3D now - lastReadTime; > =09=09=09=09lastReadTime =3D now; > =09=09=09=09System.out.println(new String(frame)); > =09=09=09=09System.out.println("Time since last read: " + timeSinceLastRe= ad + "ms"); > =09=09=09=09if (timeSinceLastRead > 15000) { > =09=09=09=09=09fail("Data not received for " + timeSinceLastRead + "ms"); > =09=09=09=09} > =09=09=09} > =09=09} finally { > =09=09=09if (socket !=3D null) { > =09=09=09=09socket.close(); > =09=09=09} > =09=09=09broker.stop(); > =09=09} > =09} > =09private BrokerService createAndStartBroker() throws Exception { > =09=09BrokerService broker =3D new BrokerService(); > =09=09broker.addConnector("stomp://localhost:61613"); > =09=09broker.setStartAsync(false); > =09=09broker.setDeleteAllMessagesOnStartup(true); > =09=09broker.start(); > =09=09return broker; > =09} > } > {code} > For the initial read of the CONNECTED frame I see: > {noformat} > Time since last read: 49ms > {noformat} > However, it's then almost 20 seconds before a heart-beat's sent: > {noformat} > Time since last read: 19994ms > {noformat} > If I comment out the fail(=E2=80=A6) line in the test, after the first he= artbeat taking almost 20000ms to be sent, things settle down and a heartbea= t's received every 10000ms. > It looks like the write checker wakes up every 10000ms. The first time it= wakes up, it notices that the CONNECTED frame was sent and does nothing. I= t then sleeps for a further 10000ms before checking again. As the CONNECTED= frame was sent very early in the first 10000ms window, this leads to it ta= king almost 20000ms for the first heart-beat to be sent. From this point, a= s no further data frames are sent, the write checker wakes up and sends a h= eart-beat every 10000ms. > In short, I don't think ActiveMQ is adhering to the requirement that "the= sender MUST send new data over the network connection at least every m= illiseconds". -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs For more information on JIRA, see: http://www.atlassian.com/software/jira