Fix the setting of the connection metadata

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@417391 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrian T. Co 2006-06-27 09:48:00 +00:00
parent b1d2279145
commit ffcbd0c015
3 changed files with 21 additions and 21 deletions

View File

@ -79,27 +79,8 @@ public abstract class AbstractJmsClient {
public Connection getConnection() throws JMSException {
if (jmsConnection == null) {
jmsConnection = factory.createConnection();
// Get Connection Metadata
getClient().setJmsProvider(jmsConnection.getMetaData().getJMSProviderName() + " " + jmsConnection.getMetaData().getProviderVersion());
getClient().setJmsVersion("JMS " + jmsConnection.getMetaData().getJMSVersion());
String jmsProperties = "";
Enumeration props = jmsConnection.getMetaData().getJMSXPropertyNames();
while (props.hasMoreElements()) {
jmsProperties += (props.nextElement().toString() + ",");
log.info("Creating JMS Connection: Provider=" + getClient().getJmsProvider() + ", JMS Spec=" + getClient().getJmsVersion());
}
if (jmsProperties.length() > 0) {
// Remove the last comma
jmsProperties = jmsProperties.substring(0, jmsProperties.length()-1);
}
getClient().setJmsProperties(jmsProperties);
}
log.info("Using JMS Connection:" +
" Provider=" + getClient().getJmsProvider() +
", JMS Spec=" + getClient().getJmsVersion() +
", JMS Properties=" + getClient().getJmsProperties());
return jmsConnection;
}

View File

@ -32,7 +32,9 @@ import org.apache.activemq.tool.spi.SPIConnectionFactory;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.ConnectionMetaData;
import java.util.Properties;
import java.util.Enumeration;
import java.io.IOException;
public abstract class AbstractJmsClientSystem extends AbstractObjectProperties {
@ -52,6 +54,8 @@ public abstract class AbstractJmsClientSystem extends AbstractObjectProperties {
// Create connection factory
jmsConnFactory = loadJmsFactory(getSysTest().getSpiClass(), factory.getFactorySettings());
setProviderMetaData(jmsConnFactory.createConnection().getMetaData(), getJmsClientProperties());
// Create performance sampler
PerformanceReportWriter writer = createPerfWriter();
tpSampler.setPerfReportWriter(writer);
@ -206,5 +210,21 @@ public abstract class AbstractJmsClientSystem extends AbstractObjectProperties {
}
}
protected void setProviderMetaData(ConnectionMetaData metaData, JmsClientProperties props) throws JMSException {
props.setJmsProvider(metaData.getJMSProviderName() + "-" + metaData.getProviderVersion());
props.setJmsVersion(metaData.getJMSVersion());
String jmsProperties = "";
Enumeration jmsProps = metaData.getJMSXPropertyNames();
while (jmsProps.hasMoreElements()) {
jmsProperties += (jmsProps.nextElement().toString() + ",");
}
if (jmsProperties.length() > 0) {
// Remove the last comma
jmsProperties = jmsProperties.substring(0, jmsProperties.length()-1);
}
props.setJmsProperties(jmsProperties);
}
protected abstract void runJmsClient(String clientName, int clientDestIndex, int clientDestCount);
}

View File

@ -23,7 +23,6 @@ import java.util.StringTokenizer;
import java.util.Properties;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Arrays;
import java.lang.reflect.Method;
import java.lang.reflect.Field;