mirror of https://github.com/apache/activemq.git
Configured Jmeter related files to accomodate SwiftMQ testing, and added radio button for Asynchronous/NonAsynchronous sending
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@397425 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40b96b1b8f
commit
b71a9f6a94
|
@ -61,6 +61,7 @@ public class Consumer extends Sampler implements MessageListener {
|
|||
|
||||
private int batchCounter = 0;
|
||||
|
||||
private static long ID = 0;
|
||||
static {
|
||||
log.info("Protocol Handler name=" + getClassname());
|
||||
log.info("Status prefix=" + STATUS_PREFIX);
|
||||
|
@ -131,15 +132,21 @@ public class Consumer extends Sampler implements MessageListener {
|
|||
Connection connection = ServerConnectionFactory.createConnectionFactory(this.getURL(),
|
||||
this.getMQServer(),
|
||||
this.getTopic(),
|
||||
this.getEmbeddedBroker());
|
||||
this.getAsyncSend());
|
||||
|
||||
if (this.getDurable()) {
|
||||
if ((ServerConnectionFactory.JORAM_SERVER.equals(this.getMQServer())) ||
|
||||
(ServerConnectionFactory.MANTARAY_SERVER.equals(this.getMQServer()))) {
|
||||
//Id set by server
|
||||
} else {
|
||||
IdGenerator idGenerator = new IdGenerator();
|
||||
connection.setClientID(idGenerator.generateId());
|
||||
if ((ServerConnectionFactory.SWIFTMQ_SERVER.equals(this.getMQServer()))) {
|
||||
ID += 1;
|
||||
String strId = String.valueOf(ID);
|
||||
connection.setClientID(strId);
|
||||
} else {
|
||||
IdGenerator idGenerator = new IdGenerator();
|
||||
connection.setClientID(idGenerator.generateId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,6 +198,20 @@ public class Consumer extends Sampler implements MessageListener {
|
|||
QueueReceiver receiver = ((QueueSession) session).createReceiver(queue);
|
||||
consumer = (MessageConsumer) receiver;
|
||||
}
|
||||
} else if (ServerConnectionFactory.SWIFTMQ_SERVER.equals(this.getMQServer())) {
|
||||
if (this.getTopic()) {
|
||||
Topic topic = (Topic) destination;
|
||||
if (this.getDurable()) {
|
||||
consumer = ((TopicSession) session).createDurableSubscriber(topic,"durableSubscriber");
|
||||
} else {
|
||||
consumer = ((TopicSession) session).createSubscriber(topic);
|
||||
}
|
||||
} else {
|
||||
subject = "testqueue@router1";
|
||||
Queue queue = ((QueueSession) session).createQueue(subject);
|
||||
QueueReceiver receiver = ((QueueSession) session).createReceiver(queue);
|
||||
consumer = (MessageConsumer) receiver;
|
||||
}
|
||||
} else {
|
||||
if (this.getDurable() && this.getTopic()) {
|
||||
consumer = session.createDurableSubscriber((Topic) destination, getClass().getName());
|
||||
|
@ -299,6 +320,8 @@ public class Consumer extends Sampler implements MessageListener {
|
|||
cons.setMQServer(ServerConnectionFactory.JORAM_SERVER);
|
||||
} else if (mqServer.equalsIgnoreCase("MANTARAY")) {
|
||||
cons.setMQServer(ServerConnectionFactory.MANTARAY_SERVER);
|
||||
} else if (mqServer.equalsIgnoreCase("SWIFTMQ")) {
|
||||
cons.setMQServer(ServerConnectionFactory.SWIFTMQ_SERVER);
|
||||
} else if (mqServer.equalsIgnoreCase("ACTIVEMQ")) {
|
||||
//Run with the default broker
|
||||
} else {
|
||||
|
@ -309,6 +332,7 @@ public class Consumer extends Sampler implements MessageListener {
|
|||
System.out.print("OPENJMS | ");
|
||||
System.out.print("JORAM | ");
|
||||
System.out.print("MANTARAY |");
|
||||
System.out.print("SWIFTMQ |");
|
||||
System.out.println("ACTIVEMQ ]");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -156,10 +156,11 @@ public class Producer extends Sampler implements TestListener {
|
|||
connection = ServerConnectionFactory.createConnectionFactory(this.getURL(),
|
||||
this.getMQServer(),
|
||||
this.getTopic(),
|
||||
this.getEmbeddedBroker());
|
||||
this.getAsyncSend());
|
||||
|
||||
if (this.getDurable()) {
|
||||
if ((ServerConnectionFactory.JORAM_SERVER.equals(this.getMQServer()))||
|
||||
(ServerConnectionFactory.SWIFTMQ_SERVER.equals(this.getMQServer()))||
|
||||
(ServerConnectionFactory.MANTARAY_SERVER.equals(this.getMQServer()))) {
|
||||
//Id set be server
|
||||
|
||||
|
@ -195,7 +196,13 @@ public class Producer extends Sampler implements TestListener {
|
|||
}
|
||||
|
||||
} else {
|
||||
if((ServerConnectionFactory.SWIFTMQ_SERVER.equals(this.getMQServer())) && !this.getTopic()){
|
||||
Queue strQ = session.createQueue("testqueue@router1");
|
||||
QueueSender queuePublisher = ((QueueSession)session).createSender(strQ);
|
||||
publisher = queuePublisher;
|
||||
} else {
|
||||
publisher = session.createProducer(destination);
|
||||
}
|
||||
}
|
||||
|
||||
long msgIntervalInMins = this.getMsgInterval();
|
||||
|
@ -438,6 +445,8 @@ public class Producer extends Sampler implements TestListener {
|
|||
prod.setMQServer(ServerConnectionFactory.JORAM_SERVER);
|
||||
} else if (mqServer.equalsIgnoreCase("MANTARAY")) {
|
||||
prod.setMQServer(ServerConnectionFactory.MANTARAY_SERVER);
|
||||
} else if (mqServer.equalsIgnoreCase("SWIFTMQ")) {
|
||||
prod.setMQServer(ServerConnectionFactory.SWIFTMQ_SERVER);
|
||||
} else if (mqServer.equalsIgnoreCase("ACTIVEMQ")) {
|
||||
//Run with the default broker
|
||||
} else {
|
||||
|
@ -448,6 +457,7 @@ public class Producer extends Sampler implements TestListener {
|
|||
System.out.print("OPENJMS | " );
|
||||
System.out.print("JORAM |");
|
||||
System.out.print("MANTARAY |");
|
||||
System.out.print("SWIFTMQ |");
|
||||
System.out.println("ACTIVEMQ ]");
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public class Sampler extends AbstractSampler {
|
|||
public static final String MSGINTERVAL = "Sampler.msginterval";
|
||||
public static final String TRANSACTED = "Sampler.transacted";
|
||||
public static final String BATCHSIZE = "Sampler.batchsize";
|
||||
public static final String ASYNC_SEND = "Sampler.async_send";
|
||||
public static final String CONFIG_SUBJECT = "TOOL.DEFAULT.CONFIG";
|
||||
public static final String CONFIRM_SUBJECT = "TOOL.DEFAULT.CONFIRM";
|
||||
public static final String PUBLISH_MSG = "true";
|
||||
|
@ -437,6 +438,20 @@ public class Sampler extends AbstractSampler {
|
|||
return getPropertyAsInt(BATCHSIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether to use Asynchronous Send.
|
||||
*/
|
||||
protected boolean getAsyncSend() {
|
||||
return getPropertyAsBoolean(ASYNC_SEND);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newAsyncSend - when to use Asynchronous Send.
|
||||
*/
|
||||
protected void setAsyncSend(String newAsyncSend) {
|
||||
this.setProperty(ASYNC_SEND, newAsyncSend);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param inpublisher - MessageProducer object
|
||||
|
|
|
@ -60,9 +60,12 @@ public class ConsumerConfigGui extends AbstractConfigGui {
|
|||
private static final String OPENJMS_SERVER = JMeterUtils.getResString("openjms_server");
|
||||
private static final String JORAM_SERVER = JMeterUtils.getResString("joram_server");
|
||||
private static final String MANTARAY_SERVER = JMeterUtils.getResString("mantaray_server");
|
||||
private static final String SWIFTMQ_SERVER = JMeterUtils.getResString("swiftmq_server");
|
||||
private static final String TRANSACTED = "transacted";
|
||||
private static final String NONTRANSACTED = "nontransacted";
|
||||
private static final String BATCHSIZE = "batchsize";
|
||||
private static final String ASYNC_SEND = "async_send";
|
||||
private static final String NON_ASYNC_SEND = "non_async_send";
|
||||
|
||||
private JTextField setURL;
|
||||
private JTextField setDuration;
|
||||
|
@ -78,6 +81,8 @@ public class ConsumerConfigGui extends AbstractConfigGui {
|
|||
private JRadioButton setTransacted;
|
||||
private JRadioButton setNonTransacted;
|
||||
private JTextField setBatchSize;
|
||||
private JRadioButton setAsyncSend;
|
||||
private JRadioButton setNonAsyncSend;
|
||||
|
||||
private boolean displayName = true;
|
||||
|
||||
|
@ -165,6 +170,19 @@ public class ConsumerConfigGui extends AbstractConfigGui {
|
|||
setBatchSize.setText("");
|
||||
}
|
||||
}
|
||||
if (element.getProperty(Consumer.ASYNC_SEND) == null) {
|
||||
setAsyncSend.setSelected(true);
|
||||
setNonAsyncSend.setSelected(false);
|
||||
|
||||
} else {
|
||||
if (element.getPropertyAsBoolean(Consumer.ASYNC_SEND)) {
|
||||
setAsyncSend.setSelected(true);
|
||||
setNonAsyncSend.setSelected(false);
|
||||
} else {
|
||||
setAsyncSend.setSelected(false);
|
||||
setNonAsyncSend.setSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,6 +215,7 @@ public class ConsumerConfigGui extends AbstractConfigGui {
|
|||
element.setProperty(Consumer.MQSERVER, setMQServer.getSelectedItem().toString());
|
||||
element.setProperty(Consumer.TRANSACTED, JOrphanUtils.booleanToString(setTransacted.isSelected()));
|
||||
element.setProperty(Consumer.BATCHSIZE, setBatchSize.getText());
|
||||
element.setProperty(Consumer.ASYNC_SEND, JOrphanUtils.booleanToString(setAsyncSend.isSelected()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -398,7 +417,8 @@ public class ConsumerConfigGui extends AbstractConfigGui {
|
|||
TIBCOMQ_SERVER,
|
||||
OPENJMS_SERVER,
|
||||
JORAM_SERVER,
|
||||
MANTARAY_SERVER};
|
||||
MANTARAY_SERVER,
|
||||
SWIFTMQ_SERVER};
|
||||
|
||||
JLabel label = new JLabel(JMeterUtils.getResString("form_mq_servers"));
|
||||
setMQServer = new JComboBox(mqServers);
|
||||
|
@ -478,6 +498,57 @@ public class ConsumerConfigGui extends AbstractConfigGui {
|
|||
return transactionPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the Asynchronous Send Panel.
|
||||
*
|
||||
* @return asyncSendPanel
|
||||
*/
|
||||
private JPanel createAsyncSendPanel() {
|
||||
JLabel labelSendType = new JLabel(JMeterUtils.getResString("form_msg_send_type"));
|
||||
|
||||
//create Async Send Type
|
||||
JLabel labelAsyncSend = new JLabel(JMeterUtils.getResString("form_async_send"));
|
||||
setAsyncSend = new JRadioButton();
|
||||
setAsyncSend.setName(ASYNC_SEND);
|
||||
labelAsyncSend.setLabelFor(setAsyncSend);
|
||||
setAsyncSend.setActionCommand(ASYNC_SEND);
|
||||
setAsyncSend.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
jRadioActionPerformedSendType(evt);
|
||||
}
|
||||
});
|
||||
setAsyncSend.setSelected(true);
|
||||
|
||||
//create Non Async Send Type
|
||||
JLabel labelNonAsyncSend = new JLabel(JMeterUtils.getResString("form_non_async_send"));
|
||||
setNonAsyncSend = new JRadioButton();
|
||||
setNonAsyncSend.setName(NON_ASYNC_SEND);
|
||||
labelNonAsyncSend.setLabelFor(setNonAsyncSend);
|
||||
setNonAsyncSend.setActionCommand(NON_ASYNC_SEND);
|
||||
setNonAsyncSend.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
jRadioActionPerformedSendType(evt);
|
||||
}
|
||||
});
|
||||
|
||||
setNonAsyncSend.setSelected(false);
|
||||
FlowLayout flow = new FlowLayout(FlowLayout.LEFT);
|
||||
flow.setHgap(0);
|
||||
flow.setVgap(0);
|
||||
|
||||
JPanel sendTypePanel = new JPanel(flow);
|
||||
sendTypePanel.add(labelSendType);
|
||||
sendTypePanel.add(new JLabel(" "));
|
||||
sendTypePanel.add(setAsyncSend);
|
||||
sendTypePanel.add(labelAsyncSend);
|
||||
sendTypePanel.add(new JLabel(" "));
|
||||
sendTypePanel.add(setNonAsyncSend);
|
||||
sendTypePanel.add(labelNonAsyncSend);
|
||||
sendTypePanel.add(new JLabel(" "));
|
||||
|
||||
return sendTypePanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the gui components.
|
||||
*/
|
||||
|
@ -499,6 +570,7 @@ public class ConsumerConfigGui extends AbstractConfigGui {
|
|||
mainPanel.add(createDurablePanel());
|
||||
mainPanel.add(createTopicPanel());
|
||||
mainPanel.add(createTransactedPanel());
|
||||
mainPanel.add(createAsyncSendPanel());
|
||||
mainPanel.add(createMQServerPanel());
|
||||
|
||||
add(mainPanel, BorderLayout.CENTER);
|
||||
|
@ -564,4 +636,18 @@ public class ConsumerConfigGui extends AbstractConfigGui {
|
|||
setBatchSize.setText("");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param evt - event triggered.
|
||||
*/
|
||||
private void jRadioActionPerformedSendType(ActionEvent evt) {
|
||||
String evtActionCommand = evt.getActionCommand();
|
||||
|
||||
if (evtActionCommand.equals(ASYNC_SEND)) {
|
||||
setAsyncSend.setSelected(true);
|
||||
setNonAsyncSend.setSelected(false);
|
||||
} else if (evtActionCommand.equals(NON_ASYNC_SEND)) {
|
||||
setAsyncSend.setSelected(false);
|
||||
setNonAsyncSend.setSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,9 +62,12 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
private static final String OPENJMS_SERVER = JMeterUtils.getResString("openjms_server");
|
||||
private static final String JORAM_SERVER = JMeterUtils.getResString("joram_server");
|
||||
private static final String MANTARAY_SERVER = JMeterUtils.getResString("mantaray_server");
|
||||
private static final String SWIFTMQ_SERVER = JMeterUtils.getResString("swiftmq_server");
|
||||
private static final String TRANSACTED = "transacted";
|
||||
private static final String NONTRANSACTED = "nontransacted";
|
||||
private static final String BATCHSIZE = "batchsize";
|
||||
private static final String ASYNC_SEND = "async_send";
|
||||
private static final String NON_ASYNC_SEND = "non_async_send";
|
||||
|
||||
private JTextField setURL;
|
||||
private JTextField setDuration;
|
||||
|
@ -83,6 +86,8 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
private JRadioButton setTransacted;
|
||||
private JRadioButton setNonTransacted;
|
||||
private JTextField setBatchSize;
|
||||
private JRadioButton setAsyncSend;
|
||||
private JRadioButton setNonAsyncSend;
|
||||
|
||||
private boolean displayName = true;
|
||||
|
||||
|
@ -191,6 +196,21 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
setBatchSize.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
if (element.getProperty(Producer.ASYNC_SEND) == null) {
|
||||
setAsyncSend.setSelected(true);
|
||||
setNonAsyncSend.setSelected(false);
|
||||
|
||||
} else {
|
||||
if (element.getPropertyAsBoolean(Producer.ASYNC_SEND)) {
|
||||
setAsyncSend.setSelected(true);
|
||||
setNonAsyncSend.setSelected(false);
|
||||
} else {
|
||||
setAsyncSend.setSelected(false);
|
||||
setNonAsyncSend.setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,6 +246,7 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
element.setProperty(Producer.MQSERVER, setMQServer.getSelectedItem().toString());
|
||||
element.setProperty(Producer.TRANSACTED, JOrphanUtils.booleanToString(setTransacted.isSelected()));
|
||||
element.setProperty(Producer.BATCHSIZE, setBatchSize.getText());
|
||||
element.setProperty(Producer.ASYNC_SEND, JOrphanUtils.booleanToString(setAsyncSend.isSelected()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -523,7 +544,7 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
setNonTransacted.setActionCommand(NONTRANSACTED);
|
||||
setNonTransacted.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
jRadioActionPerformedTransaction(evt);
|
||||
jRadioActionPerformedTransaction(evt);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -541,13 +562,13 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
|
||||
JPanel transactionPanel = new JPanel(flow);
|
||||
transactionPanel.add(labelTransactionType);
|
||||
transactionPanel.add(new JLabel(" "));
|
||||
transactionPanel.add(new JLabel(" "));
|
||||
transactionPanel.add(setNonTransacted);
|
||||
transactionPanel.add(labelNonTransacted);
|
||||
transactionPanel.add(new JLabel(" "));
|
||||
transactionPanel.add(new JLabel(" "));
|
||||
transactionPanel.add(setTransacted);
|
||||
transactionPanel.add(labelTransacted);
|
||||
transactionPanel.add(new JLabel(" "));
|
||||
transactionPanel.add(new JLabel(" "));
|
||||
transactionPanel.add(setBatchSize);
|
||||
transactionPanel.add(new JLabel(" "));
|
||||
transactionPanel.add(labelBatchSize);
|
||||
|
@ -555,6 +576,57 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
return transactionPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the Asynchronous Send Panel.
|
||||
*
|
||||
* @return asyncSendPanel
|
||||
*/
|
||||
private JPanel createAsyncSendPanel() {
|
||||
JLabel labelSendType = new JLabel(JMeterUtils.getResString("form_msg_send_type"));
|
||||
|
||||
//create Async Send Type
|
||||
JLabel labelAsyncSend = new JLabel(JMeterUtils.getResString("form_async_send"));
|
||||
setAsyncSend = new JRadioButton();
|
||||
setAsyncSend.setName(ASYNC_SEND);
|
||||
labelAsyncSend.setLabelFor(setAsyncSend);
|
||||
setAsyncSend.setActionCommand(ASYNC_SEND);
|
||||
setAsyncSend.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
jRadioActionPerformedSendType(evt);
|
||||
}
|
||||
});
|
||||
setAsyncSend.setSelected(true);
|
||||
|
||||
//create Non Async Send Type
|
||||
JLabel labelNonAsyncSend = new JLabel(JMeterUtils.getResString("form_non_async_send"));
|
||||
setNonAsyncSend = new JRadioButton();
|
||||
setNonAsyncSend.setName(NON_ASYNC_SEND);
|
||||
labelNonAsyncSend.setLabelFor(setNonAsyncSend);
|
||||
setNonAsyncSend.setActionCommand(NON_ASYNC_SEND);
|
||||
setNonAsyncSend.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
jRadioActionPerformedSendType(evt);
|
||||
}
|
||||
});
|
||||
|
||||
setNonAsyncSend.setSelected(false);
|
||||
FlowLayout flow = new FlowLayout(FlowLayout.LEFT);
|
||||
flow.setHgap(0);
|
||||
flow.setVgap(0);
|
||||
|
||||
JPanel sendTypePanel = new JPanel(flow);
|
||||
sendTypePanel.add(labelSendType);
|
||||
sendTypePanel.add(new JLabel(" "));
|
||||
sendTypePanel.add(setAsyncSend);
|
||||
sendTypePanel.add(labelAsyncSend);
|
||||
sendTypePanel.add(new JLabel(" "));
|
||||
sendTypePanel.add(setNonAsyncSend);
|
||||
sendTypePanel.add(labelNonAsyncSend);
|
||||
sendTypePanel.add(new JLabel(" "));
|
||||
|
||||
return sendTypePanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the MQ Server Combo Box.
|
||||
*
|
||||
|
@ -567,7 +639,8 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
TIBCOMQ_SERVER,
|
||||
OPENJMS_SERVER,
|
||||
JORAM_SERVER,
|
||||
MANTARAY_SERVER};
|
||||
MANTARAY_SERVER,
|
||||
SWIFTMQ_SERVER};
|
||||
|
||||
JLabel label = new JLabel(JMeterUtils.getResString("form_mq_servers"));
|
||||
setMQServer = new JComboBox(mqServers);
|
||||
|
@ -610,6 +683,7 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
mainPanel.add(createDurablePanel());
|
||||
mainPanel.add(createTopicPanel());
|
||||
mainPanel.add(createTransactedPanel());
|
||||
mainPanel.add(createAsyncSendPanel());
|
||||
mainPanel.add(createDefMsgIntervalPanel());
|
||||
mainPanel.add(createMQServerPanel());
|
||||
|
||||
|
@ -687,4 +761,19 @@ public class ProducerConfigGui extends AbstractConfigGui {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param evt - event triggered.
|
||||
*/
|
||||
private void jRadioActionPerformedSendType(ActionEvent evt) {
|
||||
String evtActionCommand = evt.getActionCommand();
|
||||
|
||||
if (evtActionCommand.equals(ASYNC_SEND)) {
|
||||
setAsyncSend.setSelected(true);
|
||||
setNonAsyncSend.setSelected(false);
|
||||
} else if (evtActionCommand.equals(NON_ASYNC_SEND)) {
|
||||
setAsyncSend.setSelected(false);
|
||||
setNonAsyncSend.setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import javax.naming.NamingException;
|
|||
import org.apache.activemq.ActiveMQConnection;
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.jmeter.util.JMeterUtils;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.mr.api.jms.MantaQueueConnectionFactory;
|
||||
import org.mr.api.jms.MantaTopicConnectionFactory;
|
||||
|
||||
|
@ -58,6 +59,7 @@ public class ServerConnectionFactory {
|
|||
public static final String JORAM_PASSWORD = JMeterUtils.getResString("joram_password");
|
||||
public static final String JORAM_NAMING_PORT = JMeterUtils.getResString("joram_naming_port");
|
||||
public static final String MANTARAY_SERVER = JMeterUtils.getResString("mantaray_server");
|
||||
public static final String SWIFTMQ_SERVER = JMeterUtils.getResString("swiftmq_server");
|
||||
|
||||
// For testing within IntelliJ running main()
|
||||
/*
|
||||
|
@ -70,12 +72,12 @@ public class ServerConnectionFactory {
|
|||
public static final String JORAM_CONNECTION_FACTORY = "!cf";
|
||||
public static final String JORAM_USERNAME = "root";
|
||||
public static final String JORAM_PASSWORD = "root";
|
||||
public static final String JORAM_NAMING_PORT = "16400";
|
||||
public static final String MANTARAY_SERVER = "Mantaray";
|
||||
*/
|
||||
|
||||
public static final String SONICMQ_TOPIC = "progress.message.jclient.TopicConnectionFactory";
|
||||
public static final String SONICMQ_QUEUE = "progress.message.jclient.QueueConnectionFactory";
|
||||
public static final String SONICMQ_CONTEXT = "com.sonicsw.jndi.mfcontext.MFContextFactory";
|
||||
public static final String SONICMQ_CONNECTION_FACTORY = "progress.message.jclient.ConnectionFactory";
|
||||
public static final String TIBCOMQ_TOPIC = "com.tibco.tibjms.TibjmsTopicConnectionFactory";
|
||||
public static final String TIBCOMQ_QUEUE = "com.tibco.tibjms.TibjmsQueueConnectionFactory";
|
||||
public static final String NAMING_CONTEXT = "org.jnp.interfaces.NamingContextFactory";
|
||||
|
@ -86,6 +88,9 @@ public class ServerConnectionFactory {
|
|||
public static final String JORAM_NAMING_CONTEXT = "fr.dyade.aaa.jndi2.client.NamingContextFactory";
|
||||
public static final String JORAM_TOPIC = "TopicConnectionFactory";
|
||||
public static final String JORAM_QUEUE = "QueueConnectionFactory";
|
||||
public static final String SWIFTMQ_CONTEXT = "com.swiftmq.jndi.InitialContextFactoryImpl";
|
||||
public static final String SWIFTMQ_CONNECTION_FACTORY = "com.swiftmq.jms.SwiftMQConnectionFactory";
|
||||
public static final String SMQP = "com.swiftmq.jms.smqp";
|
||||
public static final String NAMING_HOST = "java.naming.factory.host";
|
||||
public static final String NAMING_PORT = "java.naming.factory.post";
|
||||
|
||||
|
@ -116,14 +121,15 @@ public class ServerConnectionFactory {
|
|||
* @param url - location of the broker.
|
||||
* @param mqServer - type of broker that is running.
|
||||
* @param isTopic - type of message domain.
|
||||
* @param embeddedBroker - specified is the broker is embedded.
|
||||
* @param isAsync - specified if Send type is Asynchronous.
|
||||
* @return
|
||||
* @throws JMSException
|
||||
*/
|
||||
public static Connection createConnectionFactory(String url,
|
||||
String mqServer,
|
||||
boolean isTopic,
|
||||
boolean embeddedBroker) throws JMSException {
|
||||
boolean isAsync) throws JMSException {
|
||||
|
||||
if (SONICMQ_SERVER.equals(mqServer)) {
|
||||
//Creates a Connection object for a SONIC MQ server.
|
||||
if (isTopic) {
|
||||
|
@ -144,9 +150,7 @@ public class ServerConnectionFactory {
|
|||
InitialContext context = getInitialContext(url, JBOSSMQ_SERVER);
|
||||
ConnectionFactory factory = (ConnectionFactory) context.lookup("ConnectionFactory");
|
||||
context.close();
|
||||
|
||||
return factory.createConnection();
|
||||
|
||||
} catch (NamingException e) {
|
||||
throw new JMSException("Error creating InitialContext ", e.toString());
|
||||
}
|
||||
|
@ -200,12 +204,37 @@ public class ServerConnectionFactory {
|
|||
return factory.createQueueConnection();
|
||||
|
||||
}
|
||||
}else if (SWIFTMQ_SERVER.equals(mqServer)) {
|
||||
//Creates a Connection object for a SwiftMQ server.
|
||||
try {
|
||||
Context ictx = getInitialContext(url, SWIFTMQ_SERVER);
|
||||
if (isTopic){
|
||||
TopicConnectionFactory tcf = (TopicConnectionFactory) ictx.lookup("TopicConnectionFactory");
|
||||
// Topic topic = (Topic) ictx.lookup("testtopic");
|
||||
ictx.close();
|
||||
TopicConnection connection = tcf.createTopicConnection();
|
||||
return connection;
|
||||
} else {
|
||||
QueueConnectionFactory qcf = (QueueConnectionFactory) ictx.lookup("QueueConnectionFactory");
|
||||
// Queue queue = (Queue) ictx.lookup("testqueue");
|
||||
ictx.close();
|
||||
QueueConnection connection = qcf.createQueueConnection();
|
||||
return connection;
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
throw new JMSException("Error creating InitialContext ", e.toString());
|
||||
}
|
||||
} else {
|
||||
//Used to create a session from the default MQ server ActiveMQConnectionFactory.
|
||||
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
|
||||
ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();
|
||||
factory.setUseAsyncSend(true);
|
||||
|
||||
// factory.setUseAsyncSend(true);
|
||||
if(isAsync) {
|
||||
factory.setUseAsyncSend(true);
|
||||
} else {
|
||||
factory.setUseAsyncSend(false);
|
||||
}
|
||||
//System.out.println("ASYNC = " + factory.isUseAsyncSend());
|
||||
c.getPrefetchPolicy().setQueuePrefetch(1000);
|
||||
c.getPrefetchPolicy().setQueueBrowserPrefetch(1000);
|
||||
c.getPrefetchPolicy().setTopicPrefetch(1000);
|
||||
|
@ -279,7 +308,6 @@ public class ServerConnectionFactory {
|
|||
boolean isTransacted,
|
||||
String mqServer,
|
||||
boolean isTopic) throws JMSException {
|
||||
|
||||
if (OPENJMS_SERVER.equals(mqServer) || MANTARAY_SERVER.equals(mqServer)) {
|
||||
if (isTransacted) {
|
||||
if (isTopic) {
|
||||
|
@ -306,6 +334,15 @@ public class ServerConnectionFactory {
|
|||
|
||||
}
|
||||
}
|
||||
} else if (SONICMQ_SERVER.equals(mqServer)) {
|
||||
Session session = null;
|
||||
if (isTransacted) {
|
||||
session = connection.createSession(false, Session.SESSION_TRANSACTED);
|
||||
return session;
|
||||
} else {
|
||||
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
return session;
|
||||
}
|
||||
} else {
|
||||
// check when to use Transacted or Non-Transacted type.
|
||||
if (isTransacted) {
|
||||
|
@ -349,24 +386,22 @@ public class ServerConnectionFactory {
|
|||
Constructor constructor;
|
||||
Class[] classParameter = {url.getClass()};
|
||||
Object[] constArgs = {url};
|
||||
|
||||
try {
|
||||
try {
|
||||
classObject = Class.forName(connFactoryClass);
|
||||
constructor = classObject.getConstructor(classParameter);
|
||||
ConnectionFactory factory = (ConnectionFactory) constructor.newInstance(constArgs);
|
||||
|
||||
return factory.createConnection();
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new JMSException("Unable to find class ", e.toString());
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new JMSException("No such getConstructor(Class[] class) method found ", e.toString());
|
||||
throw new JMSException("No such getConstructor(Class[] class) method found ", e.toString());
|
||||
} catch (InstantiationException e) {
|
||||
throw new JMSException("Unable to instantiate class ", e.toString());
|
||||
throw new JMSException("Unable to instantiate class ", e.toString());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new JMSException("Unable to instantiate class ", e.toString());
|
||||
throw new JMSException("Unable to instantiate class ", e.toString());
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new JMSException("Unable to instantiate class ", e.toString());
|
||||
throw new JMSException("Unable to instantiate class ", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +417,7 @@ public class ServerConnectionFactory {
|
|||
Properties properties = new Properties();
|
||||
|
||||
if (JBOSSMQ_SERVER.equals(mqServer)) {
|
||||
//Creates a Context oject for JBOSS MQ server
|
||||
//Creates a Context object for JBOSS MQ server
|
||||
properties.put(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT);
|
||||
properties.put(Context.URL_PKG_PREFIXES, JNP_INTERFACES);
|
||||
properties.put(Context.PROVIDER_URL, url);
|
||||
|
@ -399,6 +434,17 @@ public class ServerConnectionFactory {
|
|||
properties.put(NAMING_HOST, getHost(url));
|
||||
properties.put(NAMING_PORT, JORAM_NAMING_PORT);
|
||||
|
||||
} else if (SWIFTMQ_SERVER.equals(mqServer)) {
|
||||
//Creates a Context object for SWIFTMQ server
|
||||
properties.put(Context.INITIAL_CONTEXT_FACTORY, SWIFTMQ_CONTEXT);
|
||||
properties.put(Context.URL_PKG_PREFIXES, SMQP);
|
||||
properties.put(Context.PROVIDER_URL, url);
|
||||
|
||||
} else if (SONICMQ_SERVER.equals(mqServer)) {
|
||||
//Creates a Context object for SONICMQ server
|
||||
properties.put(Context.INITIAL_CONTEXT_FACTORY, SONICMQ_CONTEXT);
|
||||
properties.put(Context.PROVIDER_URL, url);
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue