You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2014/07/31 18:53:46 UTC
git commit: https://issues.apache.org/jira/browse/AMQ-5301
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 <ta...@gmail.com>
Authored: Thu Jul 31 12:53:29 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
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;
}