This closes #38
This commit is contained in:
Timothy Bish 2014-07-31 12:53:29 -04:00
parent efa55278ec
commit 47ebd80b6b
1 changed files with 26 additions and 24 deletions

View File

@ -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);
}
@ -171,14 +173,14 @@ public abstract class AbstractJmsClient {
*/
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;
}