mirror of https://github.com/apache/activemq.git
aco - added a way to configure the delivery mode of the producer
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@414029 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2e018cc5ac
commit
2fa88148e5
|
@ -90,6 +90,12 @@ public class ProducerMojo
|
|||
*/
|
||||
private String destComposite;
|
||||
|
||||
/**
|
||||
* @parameter expression="${producer.deliveryMode}" default-value="nonpersistent"
|
||||
* @required
|
||||
*/
|
||||
private String deliveryMode;
|
||||
|
||||
/**
|
||||
* @parameter expression="${producer.messageSize}" default-value="1024"
|
||||
* @required
|
||||
|
@ -179,6 +185,7 @@ public class ProducerMojo
|
|||
"producer.destCount=" + destCount,
|
||||
"producer.destComposite=" + destComposite,
|
||||
|
||||
"producer.deliveryMode="+deliveryMode,
|
||||
"producer.messageSize="+messageSize,
|
||||
"producer.sendCount="+sendCount,
|
||||
"producer.sendDuration="+duration,
|
||||
|
|
|
@ -19,10 +19,8 @@ package org.apache.activemq.tool;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.jms.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -32,11 +30,14 @@ public class JmsProducerClient extends JmsPerformanceSupport {
|
|||
private static final String PREFIX_CONFIG_PRODUCER = "producer.";
|
||||
public static final String TIME_BASED_SENDING = "time";
|
||||
public static final String COUNT_BASED_SENDING = "count";
|
||||
public static final String DELIVERY_MODE_PERSISTENT = "persistent";
|
||||
public static final String DELIVERY_MODE_NON_PERSISTENT = "nonpersistent";
|
||||
|
||||
protected Properties jmsProducerSettings = new Properties();
|
||||
protected MessageProducer jmsProducer;
|
||||
protected TextMessage jmsTextMessage;
|
||||
|
||||
protected String deliveryMode = DELIVERY_MODE_NON_PERSISTENT;
|
||||
protected int messageSize = 1024; // Send 1kb messages by default
|
||||
protected long sendCount = 1000000; // Send a million messages by default
|
||||
protected long sendDuration = 5 * 60 * 1000; // Send for 5 mins by default
|
||||
|
@ -203,11 +204,27 @@ public class JmsProducerClient extends JmsPerformanceSupport {
|
|||
|
||||
public MessageProducer createJmsProducer() throws JMSException {
|
||||
jmsProducer = getSession().createProducer(null);
|
||||
if (getDeliveryMode().equalsIgnoreCase(DELIVERY_MODE_PERSISTENT)) {
|
||||
jmsProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
|
||||
} else if (getDeliveryMode().equalsIgnoreCase(DELIVERY_MODE_NON_PERSISTENT)) {
|
||||
jmsProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
|
||||
} else {
|
||||
log.warn("Unknown deliveryMode value. Defaulting to non-persistent.");
|
||||
jmsProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
|
||||
}
|
||||
return jmsProducer;
|
||||
}
|
||||
|
||||
public MessageProducer createJmsProducer(Destination dest) throws JMSException {
|
||||
jmsProducer = getSession().createProducer(dest);
|
||||
if (getDeliveryMode().equalsIgnoreCase(DELIVERY_MODE_PERSISTENT)) {
|
||||
jmsProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
|
||||
} else if (getDeliveryMode().equalsIgnoreCase(DELIVERY_MODE_NON_PERSISTENT)) {
|
||||
jmsProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
|
||||
} else {
|
||||
log.warn("Unknown deliveryMode value. Defaulting to non-persistent.");
|
||||
jmsProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
|
||||
}
|
||||
return jmsProducer;
|
||||
}
|
||||
|
||||
|
@ -239,6 +256,14 @@ public class JmsProducerClient extends JmsPerformanceSupport {
|
|||
return text + new String(data);
|
||||
}
|
||||
|
||||
public String getDeliveryMode() {
|
||||
return deliveryMode;
|
||||
}
|
||||
|
||||
public void setDeliveryMode(String deliveryMode) {
|
||||
this.deliveryMode = deliveryMode;
|
||||
}
|
||||
|
||||
public int getMessageSize() {
|
||||
return messageSize;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue