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 C5D321060E for ; Tue, 3 Sep 2013 23:22:09 +0000 (UTC) Received: (qmail 50153 invoked by uid 500); 3 Sep 2013 23:22:09 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 50122 invoked by uid 500); 3 Sep 2013 23:22:09 -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 50114 invoked by uid 99); 3 Sep 2013 23:22:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Sep 2013 23:22:09 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.n.gale@gmail.com designates 209.85.219.47 as permitted sender) Received: from [209.85.219.47] (HELO mail-oa0-f47.google.com) (209.85.219.47) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Sep 2013 23:22:05 +0000 Received: by mail-oa0-f47.google.com with SMTP id g12so7683061oah.34 for ; Tue, 03 Sep 2013 16:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=uFWF/OTwY1DGz4i4L4l8+K3DU31H7AFK8AKhFXuxgqY=; b=iZJIf9i6zhrQAj8jqijIHP1IjRYN0/+KPsEAbJfRULcA+JnhZarAyt5ItgBn7O03bA r7Ci7PIebUIrT9YPT8GN3FcuJ229CDzn5F31bFAtpBo/VCtT+3wIivFOBbxE0FDah7XQ h/dtzxv/1rCAodxSrSCH6saLwJVjoS1T3TaD4daGDExHQTwA/IcXtWi9f9d6aCrfnUSn /KaTN1uKvgThaYnekz2uxIpJ6BaxDoJf/vR0K2ZA2sGAIBKutbxJ750rZB3kCdwRdSnp XsTWG/CPQ4Odw6biB5uy049Um9lqr7HOLIOVj67biyE47zKT1c0Th80ePk4tiFr5DoE3 9gDA== X-Received: by 10.182.61.104 with SMTP id o8mr10073745obr.59.1378250504744; Tue, 03 Sep 2013 16:21:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.38.10 with HTTP; Tue, 3 Sep 2013 16:21:14 -0700 (PDT) In-Reply-To: References: From: Paul Gale Date: Tue, 3 Sep 2013 19:21:14 -0400 Message-ID: Subject: Re: [jira] [Commented] (AMQ-4710) The first heart-beat after a connection becomes idle isn't sent as quickly as it should be To: dev Content-Type: multipart/alternative; boundary=e89a8fb1ef6abf376004e582f3d1 X-Virus-Checked: Checked by ClamAV on apache.org --e89a8fb1ef6abf376004e582f3d1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This change won't work anyways. How do you propose one unit test multi-threaded code in a repeatable manner in Java? :) Examples and guidance much appreciated. On Tue, Sep 3, 2013 at 6:55 PM, Timothy Bish (JIRA) wrote= : > > [ > https://issues.apache.org/jira/browse/AMQ-4710?page=3Dcom.atlassian.jira.= plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D13757200#c= omment-13757200] > > Timothy Bish commented on AMQ-4710: > ----------------------------------- > > You'd need to submit the change as a patch, can't tell what's changed > above. Also tests to show there's an issue. > > > The first heart-beat after a connection becomes idle isn't sent as > quickly 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 > > > > After ActiveMQ sends a stomp frame, it may not send a heart-beat for up > to 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 { > > @Test > > public void heartbeats() throws Exception { > > BrokerService broker =3D createAndStartBroker(); > > Socket socket =3D null; > > try { > > socket =3D new Socket("localhost", 61613); > > byte[] connectFrame =3D > "CONNECT\nheart-beat:0,10000\naccept-version:1.2\n\n\0".getBytes(); > > socket.getOutputStream().write(connectFrame); > > byte[] buffer =3D new byte[4096]; > > long lastReadTime =3D System.currentTimeMillis(); > > while (true) { > > int read =3D > socket.getInputStream().read(buffer); > > byte[] frame =3D Arrays.copyOf(buffer, re= ad); > > long now =3D System.currentTimeMillis(); > > long timeSinceLastRead =3D now - > lastReadTime; > > lastReadTime =3D now; > > System.out.println(new String(frame)); > > System.out.println("Time since last read: > " + timeSinceLastRead + "ms"); > > if (timeSinceLastRead > 15000) { > > fail("Data not received for " + > timeSinceLastRead + "ms"); > > } > > } > > } finally { > > if (socket !=3D null) { > > socket.close(); > > } > > broker.stop(); > > } > > } > > private BrokerService createAndStartBroker() throws Exception { > > BrokerService broker =3D new BrokerService(); > > broker.addConnector("stomp://localhost:61613"); > > broker.setStartAsync(false); > > broker.setDeleteAllMessagesOnStartup(true); > > broker.start(); > > return broker; > > } > > } > > {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 = heartbeat > taking almost 20000ms to be sent, things settle down and a heartbeat'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 nothin= g. > It then sleeps for a further 10000ms before checking again. As the > CONNECTED frame was sent very early in the first 10000ms window, this lea= ds > to it taking almost 20000ms for the first heart-beat to be sent. From thi= s > point, as no further data frames are sent, the write checker wakes up and > sends a heart-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 > milliseconds". > > -- > This message is automatically generated by JIRA. > If you think it was sent incorrectly, please contact your JIRA > administrators > For more information on JIRA, see: http://www.atlassian.com/software/jira > --e89a8fb1ef6abf376004e582f3d1--