Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5123B1101D for ; Thu, 31 Jul 2014 16:53:47 +0000 (UTC) Received: (qmail 31952 invoked by uid 500); 31 Jul 2014 16:53:47 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 31910 invoked by uid 500); 31 Jul 2014 16:53:47 -0000 Mailing-List: contact commits-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 commits@activemq.apache.org Received: (qmail 31899 invoked by uid 99); 31 Jul 2014 16:53:47 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Jul 2014 16:53:47 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E8E2B9BBECF; Thu, 31 Jul 2014 16:53:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: https://issues.apache.org/jira/browse/AMQ-5301 Date: Thu, 31 Jul 2014 16:53:46 +0000 (UTC) Repository: activemq Updated Branches: refs/heads/trunk efa55278e -> 47ebd80b6 https://issues.apache.org/jira/browse/AMQ-5301 This closes #38 Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/47ebd80b Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/47ebd80b Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/47ebd80b Branch: refs/heads/trunk Commit: 47ebd80b6ba3cf2e753a47cab4bbff9576e840f7 Parents: efa5527 Author: Timothy Bish Authored: Thu Jul 31 12:53:29 2014 -0400 Committer: Timothy Bish Committed: Thu Jul 31 12:53:29 2014 -0400 ---------------------------------------------------------------------- .../apache/activemq/tool/AbstractJmsClient.java | 50 ++++++++++---------- 1 file changed, 26 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/47ebd80b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java ---------------------------------------------------------------------- diff --git a/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java index 12bc28c..07e7c2f 100644 --- a/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java +++ b/activemq-tooling/activemq-perf-maven-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java @@ -37,7 +37,7 @@ public abstract class AbstractJmsClient { protected int destCount = 1; protected int destIndex; protected String clientName = ""; - + private int internalTxCounter = 0; public AbstractJmsClient(ConnectionFactory factory) { @@ -117,19 +117,21 @@ public abstract class AbstractJmsClient { } else { Destination[] dest = new Destination[destCount]; for (int i = 0; i < destCount; i++) { - dest[i] = createDestination(getClient().getDestName() + "." + (destIndex + i)); + dest[i] = createDestination(withDestinationSuffix(getClient().getDestName(), i, destCount)); } - return dest; } } + private String withDestinationSuffix(String name, int destIndex, int destCount) { + return (destCount == 1) ? name : name + "." + destIndex; + } + public Destination createCompositeDestination(int destIndex, int destCount) throws JMSException { return createCompositeDestination(getClient().getDestName(), destIndex, destCount); } protected Destination createCompositeDestination(String name, int destIndex, int destCount) throws JMSException { - String compDestName; String simpleName; if (name.startsWith("queue://")) { @@ -140,13 +142,13 @@ public abstract class AbstractJmsClient { simpleName = name; } - int i; - compDestName = name + "." + destIndex + ","; // First destination - for (i = 1; i < destCount - 1; i++) { - compDestName += simpleName + "." + (destIndex + i) + ","; + String compDestName = ""; + for (int i = 0; i < destCount; i++) { + if (i > 0) { + compDestName += ","; + } + compDestName += withDestinationSuffix(simpleName, i, destCount); } - // Last destination (minus the comma) - compDestName += simpleName + "." + (destIndex + i); return createDestination(compDestName); } @@ -161,24 +163,24 @@ public abstract class AbstractJmsClient { } } - /** - * Helper method that checks if session is - * transacted and whether to commit the tx based on commitAfterXMsgs - * property. - * - * @return true if transaction was committed. + /** + * Helper method that checks if session is + * transacted and whether to commit the tx based on commitAfterXMsgs + * property. + * + * @return true if transaction was committed. * @throws JMSException in case the call to JMS Session.commit() fails. */ public boolean commitTxIfNecessary() throws JMSException { - - internalTxCounter++; + + internalTxCounter++; if (getClient().isSessTransacted()) { - if ((internalTxCounter % getClient().getCommitAfterXMsgs()) == 0) { - LOG.debug("Committing transaction."); - internalTxCounter = 0; - getSession().commit(); - return true; - } + if ((internalTxCounter % getClient().getCommitAfterXMsgs()) == 0) { + LOG.debug("Committing transaction."); + internalTxCounter = 0; + getSession().commit(); + return true; + } } return false; }