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;
|
private String destComposite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @parameter expression="${producer.deliveryMode}" default-value="nonpersistent"
|
||||||
|
* @required
|
||||||
|
*/
|
||||||
|
private String deliveryMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="${producer.messageSize}" default-value="1024"
|
* @parameter expression="${producer.messageSize}" default-value="1024"
|
||||||
* @required
|
* @required
|
||||||
|
@ -179,6 +185,7 @@ public class ProducerMojo
|
||||||
"producer.destCount=" + destCount,
|
"producer.destCount=" + destCount,
|
||||||
"producer.destComposite=" + destComposite,
|
"producer.destComposite=" + destComposite,
|
||||||
|
|
||||||
|
"producer.deliveryMode="+deliveryMode,
|
||||||
"producer.messageSize="+messageSize,
|
"producer.messageSize="+messageSize,
|
||||||
"producer.sendCount="+sendCount,
|
"producer.sendCount="+sendCount,
|
||||||
"producer.sendDuration="+duration,
|
"producer.sendDuration="+duration,
|
||||||
|
|
|
@ -19,10 +19,8 @@ package org.apache.activemq.tool;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import javax.jms.Destination;
|
import javax.jms.*;
|
||||||
import javax.jms.JMSException;
|
|
||||||
import javax.jms.MessageProducer;
|
|
||||||
import javax.jms.TextMessage;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -32,11 +30,14 @@ public class JmsProducerClient extends JmsPerformanceSupport {
|
||||||
private static final String PREFIX_CONFIG_PRODUCER = "producer.";
|
private static final String PREFIX_CONFIG_PRODUCER = "producer.";
|
||||||
public static final String TIME_BASED_SENDING = "time";
|
public static final String TIME_BASED_SENDING = "time";
|
||||||
public static final String COUNT_BASED_SENDING = "count";
|
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 Properties jmsProducerSettings = new Properties();
|
||||||
protected MessageProducer jmsProducer;
|
protected MessageProducer jmsProducer;
|
||||||
protected TextMessage jmsTextMessage;
|
protected TextMessage jmsTextMessage;
|
||||||
|
|
||||||
|
protected String deliveryMode = DELIVERY_MODE_NON_PERSISTENT;
|
||||||
protected int messageSize = 1024; // Send 1kb messages by default
|
protected int messageSize = 1024; // Send 1kb messages by default
|
||||||
protected long sendCount = 1000000; // Send a million 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
|
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 {
|
public MessageProducer createJmsProducer() throws JMSException {
|
||||||
jmsProducer = getSession().createProducer(null);
|
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;
|
return jmsProducer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageProducer createJmsProducer(Destination dest) throws JMSException {
|
public MessageProducer createJmsProducer(Destination dest) throws JMSException {
|
||||||
jmsProducer = getSession().createProducer(dest);
|
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;
|
return jmsProducer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +256,14 @@ public class JmsProducerClient extends JmsPerformanceSupport {
|
||||||
return text + new String(data);
|
return text + new String(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDeliveryMode() {
|
||||||
|
return deliveryMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeliveryMode(String deliveryMode) {
|
||||||
|
this.deliveryMode = deliveryMode;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMessageSize() {
|
public int getMessageSize() {
|
||||||
return messageSize;
|
return messageSize;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue