activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dflo...@apache.org
Subject svn commit: r397425 - in /incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq: sampler/ sampler/config/gui/ util/connection/
Date Thu, 27 Apr 2006 05:49:15 GMT
Author: dflores
Date: Wed Apr 26 22:49:13 2006
New Revision: 397425

URL: http://svn.apache.org/viewcvs?rev=397425&view=rev
Log:
Configured Jmeter related files to accomodate SwiftMQ testing, and added radio button for
Asynchronous/NonAsynchronous sending

Modified:
    incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Consumer.java
    incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Producer.java
    incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Sampler.java
    incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ConsumerConfigGui.java
    incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ProducerConfigGui.java
    incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/util/connection/ServerConnectionFactory.java

Modified: incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Consumer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Consumer.java?rev=397425&r1=397424&r2=397425&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Consumer.java (original)
+++ incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Consumer.java Wed
Apr 26 22:49:13 2006
@@ -61,6 +61,7 @@
 
     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 @@
         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 @@
                 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 @@
                 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 @@
                 System.out.print("OPENJMS | ");
                 System.out.print("JORAM | ");
                 System.out.print("MANTARAY |");
+                System.out.print("SWIFTMQ |");
                 System.out.println("ACTIVEMQ ]");
                 return;
             }

Modified: incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Producer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Producer.java?rev=397425&r1=397424&r2=397425&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Producer.java (original)
+++ incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Producer.java Wed
Apr 26 22:49:13 2006
@@ -156,10 +156,11 @@
         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 @@
             }
 
         } 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 @@
                 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 @@
                 System.out.print("OPENJMS | " );
                 System.out.print("JORAM |");
                 System.out.print("MANTARAY |");
+                System.out.print("SWIFTMQ |");
                 System.out.println("ACTIVEMQ ]");
             }
 

Modified: incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Sampler.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Sampler.java?rev=397425&r1=397424&r2=397425&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Sampler.java (original)
+++ incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/Sampler.java Wed
Apr 26 22:49:13 2006
@@ -56,6 +56,7 @@
     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";
@@ -435,6 +436,20 @@
      */
     protected int getBatchSize() {
         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);
     }
 
     /**

Modified: incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ConsumerConfigGui.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ConsumerConfigGui.java?rev=397425&r1=397424&r2=397425&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ConsumerConfigGui.java
(original)
+++ incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ConsumerConfigGui.java
Wed Apr 26 22:49:13 2006
@@ -60,9 +60,12 @@
     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 @@
     private JRadioButton setTransacted;
     private JRadioButton setNonTransacted;
     private JTextField setBatchSize;
+    private JRadioButton setAsyncSend;
+    private JRadioButton setNonAsyncSend;
 
     private boolean displayName = true;
 
@@ -165,6 +170,19 @@
                 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 @@
         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 @@
                               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);
@@ -479,6 +499,57 @@
     }
 
     /**
+     * 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.
      */
     private void init() {
@@ -499,6 +570,7 @@
         mainPanel.add(createDurablePanel());
         mainPanel.add(createTopicPanel());
         mainPanel.add(createTransactedPanel());
+        mainPanel.add(createAsyncSendPanel());
         mainPanel.add(createMQServerPanel());
 
         add(mainPanel, BorderLayout.CENTER);
@@ -562,6 +634,20 @@
             setNonTransacted.setSelected(true);
             setBatchSize.setEnabled(false);
             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);
         }
     }
 }

Modified: incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ProducerConfigGui.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ProducerConfigGui.java?rev=397425&r1=397424&r2=397425&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ProducerConfigGui.java
(original)
+++ incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/sampler/config/gui/ProducerConfigGui.java
Wed Apr 26 22:49:13 2006
@@ -62,9 +62,12 @@
     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 @@
     private JRadioButton setTransacted;
     private JRadioButton setNonTransacted;
     private JTextField setBatchSize;
+    private JRadioButton setAsyncSend;
+    private JRadioButton setNonAsyncSend;
 
     private boolean displayName = true;
 
@@ -191,6 +196,21 @@
                 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 @@
         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 @@
         setNonTransacted.setActionCommand(NONTRANSACTED);
         setNonTransacted.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent evt) {
-                jRadioActionPerformedTransaction(evt);
+               jRadioActionPerformedTransaction(evt);
             }
         });
 
@@ -541,13 +562,13 @@
 
         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);
@@ -556,6 +577,57 @@
     }
 
     /**
+     * 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.
      *
      * @return mqServerPanel
@@ -567,7 +639,8 @@
                               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 @@
         mainPanel.add(createDurablePanel());
         mainPanel.add(createTopicPanel());
         mainPanel.add(createTransactedPanel());
+        mainPanel.add(createAsyncSendPanel());
         mainPanel.add(createDefMsgIntervalPanel());
         mainPanel.add(createMQServerPanel());
 
@@ -684,6 +758,21 @@
             setNonTransacted.setSelected(true);
             setBatchSize.setEnabled(false);
             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);
         }
     }
 

Modified: incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/util/connection/ServerConnectionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/util/connection/ServerConnectionFactory.java?rev=397425&r1=397424&r2=397425&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/util/connection/ServerConnectionFactory.java
(original)
+++ incubator/activemq/trunk/activemq-jmeter/src/java/org/activemq/util/connection/ServerConnectionFactory.java
Wed Apr 26 22:49:13 2006
@@ -40,6 +40,7 @@
 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 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 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 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 @@
      * @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 @@
                 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 @@
                 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 @@
                                         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 @@
 
                 }
             }
+        } 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 @@
         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 @@
         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);
@@ -398,6 +433,17 @@
             properties.put(Context.INITIAL_CONTEXT_FACTORY, JORAM_NAMING_CONTEXT);
             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);
 
         }
 



Mime
View raw message