Author: sebb Date: Tue Nov 11 14:03:43 2008 New Revision: 713190 URL: http://svn.apache.org/viewvc?rev=713190&view=rev Log: Major overhaul of JMS classes to: - improve thread-safety - make JMX values locale-independent - improve dynamic locale change handling Had to move JLabelledRadioI18N to core because it uses JMeterUtils
Added: jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java (contents, props changed) - copied, changed from r712912, jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledRadioI18N.java Removed: jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledRadioI18N.java Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java jakarta/jmeter/trunk/xdocs/changes.xml Copied: jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java (from r712912, jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledRadioI18N.java) URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java?p2=jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java&p1=jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledRadioI18N.java&r1=712912&r2=713190&rev=713190&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledRadioI18N.java (original) +++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java Tue Nov 11 14:03:43 2008 @@ -16,7 +16,7 @@ * */ -package org.apache.jorphan.gui; +package org.apache.jmeter.gui.util; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -34,6 +34,7 @@ import javax.swing.event.ChangeListener; import org.apache.jmeter.util.JMeterUtils; +import org.apache.jorphan.gui.JLabeledField; /** * JLabeledRadio will create a set of Radio buttons with a label. Propchange: jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Propchange: jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JLabeledRadioI18N.java ------------------------------------------------------------------------------ svn:mergeinfo = Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java?rev=713190&r1=713189&r2=713190&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java (original) +++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java Tue Nov 11 14:03:43 2008 @@ -35,7 +35,7 @@ import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.util.JMeterUtils; import org.apache.jmeter.gui.util.FilePanel; -import org.apache.jorphan.gui.JLabeledRadio; +import org.apache.jmeter.gui.util.JLabeledRadioI18N; import org.apache.jorphan.gui.JLabeledTextField; import org.apache.jorphan.gui.JLabeledTextArea; import org.apache.jorphan.gui.layout.VerticalLayout; @@ -51,58 +51,51 @@ private static final String ALL_FILES = "*.*"; //$NON-NLS-1$ - // These must not be static, otherwise Language change does not work - public final String use_file = JMeterUtils.getResString("jms_use_file"); //$NON-NLS-1$ + //++ These names are used in the JMX files, and must not be changed + public static final String USE_FILE_RSC = "jms_use_file"; //$NON-NLS-1$ + public static final String USE_RANDOM_RSC = "jms_use_random_file"; //$NON-NLS-1$ + private static final String USE_TEXT_RSC = "jms_use_text"; //$NON-NLS-1$ - public final String use_random = JMeterUtils.getResString("jms_use_random_file"); //$NON-NLS-1$ + private static final String TEXT_MSG_RSC = "jms_text_message"; //$NON-NLS-1$ + private static final String OBJECT_MSG_RSC = "jms_object_message"; //$NON-NLS-1$ + //-- + + // Button group resources + private static final String[] CONFIG_ITEMS = { USE_FILE_RSC, USE_RANDOM_RSC, USE_TEXT_RSC }; - public final String use_text = JMeterUtils.getResString("jms_use_text"); //$NON-NLS-1$ + private static final String[] MSGTYPES_ITEMS = { TEXT_MSG_RSC, OBJECT_MSG_RSC }; - private String[] items = { use_file, use_random, use_text }; + private final JCheckBox useProperties = new JCheckBox(JMeterUtils.getResString("jms_use_properties_file"), false); //$NON-NLS-1$ - private String text_msg = JMeterUtils.getResString("jms_text_message"); //$NON-NLS-1$ + private final JLabeledRadioI18N configChoice = new JLabeledRadioI18N("jms_config", CONFIG_ITEMS, USE_TEXT_RSC); //$NON-NLS-1$ - private String object_msg = JMeterUtils.getResString("jms_object_message"); //$NON-NLS-1$ + private final JLabeledTextField jndiICF = new JLabeledTextField(JMeterUtils.getResString("jms_initial_context_factory")); //$NON-NLS-1$ - private String[] msgTypes = { text_msg, object_msg }; + private final JLabeledTextField urlField = new JLabeledTextField(JMeterUtils.getResString("jms_provider_url")); //$NON-NLS-1$ - JCheckBox useProperties = new JCheckBox(JMeterUtils.getResString("jms_use_properties_file"), false); //$NON-NLS-1$ + private final JLabeledTextField jndiConnFac = new JLabeledTextField(JMeterUtils.getResString("jms_connection_factory")); //$NON-NLS-1$ - JLabeledRadio configChoice = new JLabeledRadio(JMeterUtils.getResString("jms_config"), items, use_text); //$NON-NLS-1$ + private final JLabeledTextField jmsTopic = new JLabeledTextField(JMeterUtils.getResString("jms_topic")); //$NON-NLS-1$ - JLabeledTextField jndiICF = new JLabeledTextField(JMeterUtils.getResString("jms_initial_context_factory")); //$NON-NLS-1$ + private final JCheckBox useAuth = new JCheckBox(JMeterUtils.getResString("jms_use_auth"), false); //$NON-NLS-1$ - JLabeledTextField urlField = new JLabeledTextField(JMeterUtils.getResString("jms_provider_url")); //$NON-NLS-1$ + private final JLabeledTextField jmsUser = new JLabeledTextField(JMeterUtils.getResString("jms_user")); //$NON-NLS-1$ - JLabeledTextField jndiConnFac = new JLabeledTextField(JMeterUtils.getResString("jms_connection_factory")); //$NON-NLS-1$ + private final JLabeledTextField jmsPwd = new JLabeledTextField(JMeterUtils.getResString("jms_pwd")); //$NON-NLS-1$ - JLabeledTextField jmsTopic = new JLabeledTextField(JMeterUtils.getResString("jms_topic")); //$NON-NLS-1$ + private final JLabeledTextField iterations = new JLabeledTextField(JMeterUtils.getResString("jms_itertions")); //$NON-NLS-1$ - private JCheckBox useAuth = - new JCheckBox(JMeterUtils.getResString("jms_use_auth"), false); //$NON-NLS-1$ + private final FilePanel messageFile = new FilePanel(JMeterUtils.getResString("jms_file"), ALL_FILES); //$NON-NLS-1$ - JLabeledTextField jmsUser = new JLabeledTextField(JMeterUtils.getResString("jms_user")); //$NON-NLS-1$ + private final FilePanel randomFile = new FilePanel(JMeterUtils.getResString("jms_random_file"), ALL_FILES); //$NON-NLS-1$ - JLabeledTextField jmsPwd = new JLabeledTextField(JMeterUtils.getResString("jms_pwd")); //$NON-NLS-1$ + private final JLabeledTextArea textMessage = new JLabeledTextArea(TEXT_MSG_RSC); - JLabeledTextField iterations = new JLabeledTextField(JMeterUtils.getResString("jms_itertions")); //$NON-NLS-1$ + private final JLabeledRadioI18N msgChoice = new JLabeledRadioI18N("jms_message_type", MSGTYPES_ITEMS, TEXT_MSG_RSC); //$NON-NLS-1$ - FilePanel messageFile = new FilePanel(JMeterUtils.getResString("jms_file"), ALL_FILES); //$NON-NLS-1$ + private final JPanel lookup = new JPanel(); - FilePanel randomFile = new FilePanel(JMeterUtils.getResString("jms_random_file"), ALL_FILES); //$NON-NLS-1$ - - JLabeledTextArea textMessage = new JLabeledTextArea(text_msg); - - JLabeledRadio msgChoice = new JLabeledRadio(JMeterUtils.getResString("jms_message_type"), msgTypes, text_msg); //$NON-NLS-1$ - - /** - * This is the font for the note. - */ - Font plainText = new Font("plain", Font.PLAIN, 10); //$NON-NLS-1$ - - private JPanel lookup = null; - - private JPanel messagePanel = null; + private final JPanel messagePanel = new JPanel(); public JMSPublisherGui() { init(); @@ -186,7 +179,7 @@ mainPanel.add(getNamePanel()); // Button for browsing webservice wsdl - lookup = new JPanel(); + lookup.setLayout(new VerticalLayout(6, VerticalLayout.LEFT)); mainPanel.add(lookup); lookup.add(useProperties); @@ -207,7 +200,6 @@ commonParams.add(jmsPwd); commonParams.add(iterations); - messagePanel = new JPanel(); messagePanel.setLayout(new VerticalLayout(3, VerticalLayout.LEFT)); messagePanel.add(configChoice); messagePanel.add(msgChoice); @@ -236,8 +228,8 @@ messageFile.setFilename(""); // $NON-NLS-1$ randomFile.setFilename(""); // $NON-NLS-1$ msgChoice.setText(""); // $NON-NLS-1$ - configChoice.setText(use_text); - updateConfig(use_text); + configChoice.setText(USE_TEXT_RSC); + updateConfig(USE_TEXT_RSC); iterations.setText(""); // $NON-NLS-1$ useAuth.setSelected(false); } @@ -300,12 +292,12 @@ * * @param command */ - public void updateConfig(String command) { - if (command.equals(use_text)) { + private void updateConfig(String command) { + if (command.equals(USE_TEXT_RSC)) { textMessage.setEnabled(true); messageFile.enableFile(false); randomFile.enableFile(false); - } else if (command.equals(use_random)) { + } else if (command.equals(USE_RANDOM_RSC)) { textMessage.setEnabled(false); messageFile.enableFile(false); randomFile.enableFile(true); @@ -320,9 +312,9 @@ * * @param msgType */ - public void updateMessageType(String msgType) { - if (msgType.equals(object_msg)) { - if (configChoice.getText().equals(use_text)) { + private void updateMessageType(String msgType) { + if (msgType.equals(OBJECT_MSG_RSC)) { + if (configChoice.getText().equals(USE_TEXT_RSC)) { JOptionPane.showConfirmDialog(this, JMeterUtils.getResString("jms_error_msg"), //$NON-NLS-1$ "Warning", Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java?rev=713190&r1=713189&r2=713190&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java (original) +++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java Tue Nov 11 14:03:43 2008 @@ -33,9 +33,9 @@ import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.gui.JLabeledTextField; -import org.apache.jorphan.gui.JLabeledRadio; import org.apache.jorphan.gui.layout.VerticalLayout; +import org.apache.jmeter.gui.util.JLabeledRadioI18N; import org.apache.jmeter.protocol.jms.sampler.SubscriberSampler; /** @@ -44,53 +44,49 @@ */ public class JMSSubscriberGui extends AbstractSamplerGui implements java.awt.event.ActionListener, ChangeListener { - private JCheckBox useProperties = + private final JCheckBox useProperties = new JCheckBox(JMeterUtils.getResString("jms_use_properties_file"), false); // $NON-NLS-1$ - private JLabeledTextField jndiICF = + private final JLabeledTextField jndiICF = new JLabeledTextField(JMeterUtils.getResString("jms_initial_context_factory")); // $NON-NLS-1$ - private JLabeledTextField urlField = + private final JLabeledTextField urlField = new JLabeledTextField(JMeterUtils.getResString("jms_provider_url")); // $NON-NLS-1$ - private JLabeledTextField jndiConnFac = + private final JLabeledTextField jndiConnFac = new JLabeledTextField(JMeterUtils.getResString("jms_connection_factory")); // $NON-NLS-1$ - private JLabeledTextField jmsTopic = + private final JLabeledTextField jmsTopic = new JLabeledTextField(JMeterUtils.getResString("jms_topic")); // $NON-NLS-1$ - private JLabeledTextField jmsUser = + private final JLabeledTextField jmsUser = new JLabeledTextField(JMeterUtils.getResString("jms_user")); // $NON-NLS-1$ - private JLabeledTextField jmsPwd = + private final JLabeledTextField jmsPwd = new JLabeledTextField(JMeterUtils.getResString("jms_pwd")); // $NON-NLS-1$ - private JLabeledTextField iterations = + private final JLabeledTextField iterations = new JLabeledTextField(JMeterUtils.getResString("jms_itertions")); // $NON-NLS-1$ - private JCheckBox useAuth = + private final JCheckBox useAuth = new JCheckBox(JMeterUtils.getResString("jms_use_auth"), false); //$NON-NLS-1$ - private JCheckBox readResponse = + private final JCheckBox readResponse = new JCheckBox(JMeterUtils.getResString("jms_read_response"), true); // $NON-NLS-1$ - // These must not be static, otherwise Language change does not work - public final String receive_str = JMeterUtils.getResString("jms_subscriber_receive"); // $NON-NLS-1$ + //++ Do not change these strings; they are used in JMX files to record the button settings + public final static String RECEIVE_RSC = "jms_subscriber_receive"; // $NON-NLS-1$ - public final String onmessage_str = JMeterUtils.getResString("jms_subscriber_on_message"); // $NON-NLS-1$ - - private final String[] client_items = { receive_str, onmessage_str }; - - private JLabeledRadio clientChoice = - new JLabeledRadio(JMeterUtils.getResString("jms_client_type"), client_items, // $NON-NLS-1$ - receive_str); - - /** - * This is the font for the note. - */ - //Font plainText = new Font("plain", Font.PLAIN, 10); // $NON-NLS-1$ - - private JPanel lookup = null; + public final static String ON_MESSAGE_RSC = "jms_subscriber_on_message"; // $NON-NLS-1$ + //-- + + // Button group resources + private final static String[] CLIENT_ITEMS = { RECEIVE_RSC, ON_MESSAGE_RSC }; + + private final JLabeledRadioI18N clientChoice = + new JLabeledRadioI18N("jms_client_type", CLIENT_ITEMS, RECEIVE_RSC); // $NON-NLS-1$ + + private final JPanel lookup = new JPanel(); public JMSSubscriberGui() { init(); @@ -165,7 +161,7 @@ mainPanel.add(getNamePanel()); // Button for browsing webservice wsdl - lookup = new JPanel(); + lookup.setLayout(new VerticalLayout(6, VerticalLayout.LEFT)); mainPanel.add(lookup); lookup.add(useProperties); @@ -220,7 +216,7 @@ iterations.setText(""); // $NON-NLS-1$ useAuth.setSelected(false); readResponse.setSelected(true); - clientChoice.setText(""); // $NON-NLS-1$ + clientChoice.setText(RECEIVE_RSC); } /** Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java?rev=713190&r1=713189&r2=713190&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java (original) +++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java Tue Nov 11 14:03:43 2008 @@ -22,6 +22,7 @@ import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.services.FileServer; import org.apache.jmeter.testelement.TestListener; +import org.apache.jmeter.util.JMeterUtils; import org.apache.jmeter.engine.event.LoopIterationEvent; import org.apache.jmeter.protocol.jms.control.gui.JMSPublisherGui; @@ -52,12 +53,16 @@ private static final String MESSAGE_CHOICE = "jms.config_msg_type"; //$NON-NLS-1$ //-- + // Does not need to be synch. because it is only accessed from the sampler thread + // The ClientPool does access it in a different thread, but ClientPool is fully synch. private transient Publisher PUB = null; - private StringBuffer BUFFER = new StringBuffer(); + // Does not need to be synch. because only used by the sample method as a temporary buffer + private final StringBuffer BUFFER = new StringBuffer(); private static final FileServer FSERVER = FileServer.getFileServer(); + // Cache for file. Only used by sample() in a single thread private String file_contents = null; public PublisherSampler() { @@ -83,19 +88,11 @@ * @see junit.framework.TestListener#endTest(junit.framework.Test) */ public void testEnded() { - log.info("PublisherSampler.testEnded called"); - Thread.currentThread().interrupt(); - this.PUB = null; - this.BUFFER.setLength(0); - this.BUFFER = null; + log.debug("PublisherSampler.testEnded called"); ClientPool.clearClient(); } - /** - * the implementation creates a new StringBuffer - */ public void testStarted() { - this.BUFFER = new StringBuffer(); } /** @@ -108,12 +105,12 @@ * initialize the Publisher client. * */ - public synchronized void initClient() { + private void initClient() { this.PUB = new Publisher(this.getUseJNDIPropertiesAsBoolean(), this.getJNDIInitialContextFactory(), this .getProviderUrl(), this.getConnectionFactory(), this.getTopic(), this.isUseAuth(), this.getUsername(), this.getPassword()); ClientPool.addClient(this.PUB); - log.info("PublisherSampler.initClient called"); + log.debug("PublisherSampler.initClient called"); } /** @@ -161,15 +158,15 @@ * * @return the contents for the message */ - public String getMessageContent() { - if (this.getConfigChoice().equals(JMSPublisherGui.use_file)) { + private String getMessageContent() { + if (this.getConfigChoice().equals(JMSPublisherGui.USE_FILE_RSC)) { // in the case the test uses a file, we set it locally and // prevent loading the file repeatedly if (this.file_contents == null) { this.file_contents = this.getFileContent(this.getInputFile()); } return this.file_contents; - } else if (this.getConfigChoice().equals(JMSPublisherGui.use_random)) { + } else if (this.getConfigChoice().equals(JMSPublisherGui.USE_RANDOM_RSC)) { // Maybe we should consider creating a global cache for the // random files to make JMeter more efficient. String fname = FSERVER.getRandomFile(this.getRandomPath(), new String[] { ".txt", ".obj" }) @@ -202,12 +199,25 @@ setProperty(CONFIG_CHOICE, choice); } + private static final String USE_FILE_LOCALNAME = JMeterUtils.getResString(JMSPublisherGui.USE_FILE_RSC); + private static final String USE_RANDOM_LOCALNAME = JMeterUtils.getResString(JMSPublisherGui.USE_RANDOM_RSC); + /** * return the config choice - * + * Converts from old JMX files which used the local language string */ public String getConfigChoice() { - return getPropertyAsString(CONFIG_CHOICE); + // Allow for the old JMX file which used the local language string + String config = getPropertyAsString(CONFIG_CHOICE); + if (config.equals(USE_FILE_LOCALNAME) + || config.equals(JMSPublisherGui.USE_FILE_RSC)){ + return JMSPublisherGui.USE_FILE_RSC; + } + if (config.equals(USE_RANDOM_LOCALNAME) + || config.equals(JMSPublisherGui.USE_RANDOM_RSC)){ + return JMSPublisherGui.USE_RANDOM_RSC; + } + return config; // will be the 3rd option, which is not checked specifically } /** Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java?rev=713190&r1=713189&r2=713190&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java (original) +++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java Tue Nov 11 14:03:43 2008 @@ -22,9 +22,9 @@ import javax.jms.MessageListener; import javax.jms.TextMessage; -import org.apache.jmeter.samplers.Entry; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.testelement.TestListener; +import org.apache.jmeter.util.JMeterUtils; import org.apache.jmeter.engine.event.LoopIterationEvent; import org.apache.jmeter.protocol.jms.control.gui.JMSSubscriberGui; @@ -42,17 +42,18 @@ private static final long serialVersionUID = 233L; - // private Subscriber SUBSCRIBER = null; private static final Logger log = LoggingManager.getLoggerForClass(); + // No need to synch/ - only used by sampler and ClientPool (which does its own synch) private transient ReceiveSubscriber SUBSCRIBER = null; - private StringBuffer BUFFER = new StringBuffer(); + //@GuardedBy("this") + private final StringBuffer BUFFER = new StringBuffer(); + //@GuardedBy("this") private transient int counter = 0; - private volatile boolean isRunning; - + // Don't change the string, as it is used in JMX files private static final String CLIENT_CHOICE = "jms.client_choice"; // $NON-NLS-1$ public SubscriberSampler() { @@ -67,18 +68,12 @@ } /** - * testEnded is called by Jmeter's engine. the implementation will reset the - * count, set RUN to false and clear the StringBuffer. + * testEnded is called by Jmeter's engine. + * Clears the client pool. */ - public synchronized void testEnded() { - log.info("SubscriberSampler.testEnded called"); - this.isRunning = false; - this.resetCount(); + public void testEnded() { + log.debug("SubscriberSampler.testEnded called"); ClientPool.clearClient(); - this.BUFFER = null; - if (this.SUBSCRIBER != null) { - this.SUBSCRIBER = null; - } } /* @@ -107,8 +102,8 @@ sub.resume(); ClientPool.addClient(sub); ClientPool.put(this, sub); - log.info("SubscriberSampler.initListenerClient called"); - log.info("loop count " + this.getIterations()); + log.debug("SubscriberSampler.initListenerClient called"); + log.debug("loop count " + this.getIterations()); } return sub; } @@ -116,22 +111,13 @@ /** * Create the ReceiveSubscriber client for the sampler. */ - public void initReceiveClient() { + private void initReceiveClient() { this.SUBSCRIBER = new ReceiveSubscriber(this.getUseJNDIPropertiesAsBoolean(), this .getJNDIInitialContextFactory(), this.getProviderUrl(), this.getConnectionFactory(), this.getTopic(), this.isUseAuth(), this.getUsername(), this.getPassword()); this.SUBSCRIBER.resume(); ClientPool.addClient(this.SUBSCRIBER); - log.info("SubscriberSampler.initReceiveClient called"); - } - - /* - * (non-Javadoc) - * - * @see org.apache.jmeter.samplers.Sampler#sample(org.apache.jmeter.samplers.Entry) - */ - public SampleResult sample(Entry e) { - return this.sample(); + log.debug("SubscriberSampler.initReceiveClient called"); } /** @@ -141,7 +127,7 @@ * @return the appropriate sample result */ public SampleResult sample() { - if (this.getClientChoice().equals(JMSSubscriberGui.receive_str)) { + if (this.getClientChoice().equals(JMSSubscriberGui.RECEIVE_RSC)) { return sampleWithReceive(); } else { return sampleWithListener(); @@ -157,21 +143,20 @@ SampleResult result = new SampleResult(); result.setSampleLabel(getName()); initListenerClient(); - this.isRunning = true; int loop = this.getIterationCount(); result.sampleStart(); - while (this.isRunning && this.count(0) < loop) { + while (this.count(0) < loop) { try { Thread.sleep(0, 50); - } catch (Exception e) { - log.info(e.getMessage()); + } catch (InterruptedException e) { + log.debug(e.getMessage()); } } result.sampleEnd(); result.setResponseMessage(loop + " samples messages recieved"); - synchronized (this) { + synchronized (this) {// Need to synch because buffer is shared with onMessageHandler if (this.getReadResponseAsBoolean()) { result.setResponseData(this.BUFFER.toString().getBytes()); } else { @@ -207,8 +192,8 @@ while (this.SUBSCRIBER.count(0) < loop) { try { Thread.sleep(0, 50); - } catch (Exception e) { - log.info(e.getMessage()); + } catch (InterruptedException e) { + log.debug(e.getMessage()); } } result.sampleEnd(); @@ -223,8 +208,7 @@ result.setSamplerData("Not applicable"); result.setSampleCount(loop); - this.SUBSCRIBER.clear(); - this.SUBSCRIBER.resetCount(); + this.SUBSCRIBER.reset(); return result; } @@ -279,9 +263,18 @@ /** * Return the client choice. * - * @return the client choice + * @return the client choice, either RECEIVE_RSC or ON_MESSAGE_RSC */ public String getClientChoice() { - return getPropertyAsString(CLIENT_CHOICE); + String choice = getPropertyAsString(CLIENT_CHOICE); + // Convert the old test plan entry (which is the language dependent string) to the resource name + if (choice.equals(RECEIVE_STR)){ + choice = JMSSubscriberGui.RECEIVE_RSC; + } else if (!choice.equals(JMSSubscriberGui.RECEIVE_RSC)){ + choice = JMSSubscriberGui.ON_MESSAGE_RSC; + } + return choice; } + // This was the old value that was checked for + private final static String RECEIVE_STR = JMeterUtils.getResString(JMSSubscriberGui.RECEIVE_RSC); // $NON-NLS-1$ } Modified: jakarta/jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=713190&r1=713189&r2=713190&view=diff ============================================================================== --- jakarta/jmeter/trunk/xdocs/changes.xml (original) +++ jakarta/jmeter/trunk/xdocs/changes.xml Tue Nov 11 14:03:43 2008 @@ -106,6 +106,11 @@ </p> <p> +The following deprecated methods were removed from JOrphanUtils: booleanToString(boolean) and valueOf(boolean). +Java 1.4+ has these methods in the Boolean class. +</p> + +<p> The TestElement interface has some new methods: <ul> <li>void setProperty(String key, String value, String dflt)</li> @@ -157,6 +162,8 @@ <li>Bug 34096 - Duplicate samples not eliminated when writing to CSV files</li> <li>Bug 44521 - empty variables for a POST in the HTTP Request don't get ignored</li> <li>Bug 44941 - Throughput controllers should not share global counters</li> +<li>Various ReceiveSubscriber thread-safety fixes</li> +<li>JMSPublisher and Subscriber fixes: thread-safety, support dynamic locale changes, locale independence for JMX attribute values</li> </ul> <h3>Improvements</h3> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]