modifying perf example to accept amqp connections as well

This commit is contained in:
Clebert Suconic 2015-09-21 17:45:00 -04:00
parent dc3b01036d
commit 0354944e8f
5 changed files with 66 additions and 18 deletions

View File

@ -57,6 +57,12 @@ under the License.
<artifactId>artemis-cli</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
<version>0.5.0</version>
</dependency>
</dependencies>
<profiles>

View File

@ -27,11 +27,11 @@ under the License.
<body onload="prettyPrint()">
<h1>JMS Simple Performance</h1>
<p>To start the server run <code>mvn verify -Pexample</code></p>
<p>To start the server run <code>mvn verify -Pserver</code></p>
<p>To start the listener run <code>mvn -Plistener package</code></p>
<p>To start the listener run <code>mvn -Plistener verify</code></p>
<p>To start the sender run <code>mvn -Psender package</code></p>
<p>To start the sender run <code>mvn -Psender verify</code></p>
<p>To configure the clients simply edit the <code>perf.properties</code> or <code>client.jndi.properties</code> in the
<code>src/main/resources</code> directory</p>

View File

@ -37,6 +37,7 @@ import java.util.logging.Logger;
import org.apache.activemq.artemis.utils.TokenBucketLimiter;
import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl;
import org.apache.qpid.jms.JmsConnectionFactory;
public abstract class PerfBase {
@ -99,7 +100,7 @@ public abstract class PerfBase {
boolean dupsOK = Boolean.valueOf(props.getProperty("dups-ok-acknowlege"));
boolean disableMessageID = Boolean.valueOf(props.getProperty("disable-message-id"));
boolean disableTimestamp = Boolean.valueOf(props.getProperty("disable-message-timestamp"));
boolean openwire = Boolean.valueOf(props.getProperty("openwire", "true"));
String clientLibrary = props.getProperty("client-library", "core");
String uri = props.getProperty("server-uri", "tcp://localhost:61616");
PerfBase.log.info("num-messages: " + noOfMessages);
@ -115,7 +116,7 @@ public abstract class PerfBase {
PerfBase.log.info("disable-message-timestamp: " + disableTimestamp);
PerfBase.log.info("dups-ok-acknowledge: " + dupsOK);
PerfBase.log.info("server-uri: " + uri);
PerfBase.log.info("openwire:" + openwire);
PerfBase.log.info("client-library:" + clientLibrary);
PerfParams perfParams = new PerfParams();
perfParams.setNoOfMessagesToSend(noOfMessages);
@ -130,7 +131,7 @@ public abstract class PerfBase {
perfParams.setDisableMessageID(disableMessageID);
perfParams.setDisableTimestamp(disableTimestamp);
perfParams.setDupsOK(dupsOK);
perfParams.setOpenwire(openwire);
perfParams.setLibraryType(clientLibrary);
perfParams.setUri(uri);
return perfParams;
@ -160,7 +161,7 @@ public abstract class PerfBase {
connection = factory.createConnection();
}
else {
else if (perfParams.isCore()) {
factory = new org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory(perfParams.getUri());
destination = new org.apache.activemq.artemis.jms.client.ActiveMQQueue(perfParams.getDestinationName());
@ -168,6 +169,19 @@ public abstract class PerfBase {
connection = factory.createConnection();
}
else if (perfParams.isAMQP()) {
factory = new JmsConnectionFactory(perfParams.getUri());
destination = new org.apache.activemq.artemis.jms.client.ActiveMQQueue(perfParams.getDestinationName());
connection = factory.createConnection();
Session sessionX = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = sessionX.createQueue(perfParams.getDestinationName());
sessionX.close();
}
session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
}

View File

@ -25,6 +25,12 @@ public class PerfParams implements Serializable {
private static final long serialVersionUID = -4336539641012356002L;
enum ClientLibraryType {
core, openwire, amqp
}
private ClientLibraryType libraryType;
private int noOfMessagesToSend = 1000;
private int noOfWarmupMessages;
@ -47,8 +53,6 @@ public class PerfParams implements Serializable {
private boolean disableTimestamp;
private boolean openwire;
private boolean dupsOK;
private String uri;
@ -158,10 +162,28 @@ public class PerfParams implements Serializable {
}
public boolean isOpenwire() {
return openwire;
return libraryType.equals(ClientLibraryType.openwire);
}
public void setOpenwire(boolean openwire) {
this.openwire = openwire;
public boolean isAMQP() {
return libraryType.equals(ClientLibraryType.amqp);
}
public boolean isCore() {
return libraryType.equals(ClientLibraryType.core);
}
public ClientLibraryType getLibraryType() {
return libraryType;
}
public void setLibraryType(ClientLibraryType libraryType) {
this.libraryType = libraryType;
}
public void setLibraryType(String libraryType) {
this.libraryType = ClientLibraryType.valueOf(libraryType);
}
}

View File

@ -15,17 +15,23 @@
# specific language governing permissions and limitations
# under the License.
num-messages=25000
num-messages=250000
num-warmup-messages=1000
message-size=1024
durable=true
transacted=false
batch-size=1000
drain-queue=false
destination-name=perfQueue
batch-size=100
drain-queue=true
destination-name=jms.queue.perfQueue
throttle-rate=-1
dups-ok-acknowledge=false
disable-message-id=true
disable-message-timestamp=true
server-uri=tcp://localhost:61616
openwire=false
server-uri=amqp://localhost:61616
#server-uri=tcp://localhost:61616
#valid ones are openwire,core,amqp
client-library=amqp
#client-library=openwire
#client-library=core