New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscriber ThreadGroup won't stop #2286
Comments
Bob Yetman (migrated from Bugzilla): Created attachment patch.txt: Patch to add interruptible to SubscriberSampler.java patch.txtIndex: SubscriberSampler.java
===================================================================
--- SubscriberSampler.java (revision 825637)
+++ SubscriberSampler.java (working copy)
@@ -22,6 +22,7 @@
import javax.jms.MessageListener;
import javax.jms.TextMessage;
+import org.apache.jmeter.samplers.Interruptible;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.testelement.TestListener;
import org.apache.jmeter.util.JMeterUtils;
@@ -38,7 +39,7 @@
/**
* This class implements the JMS Subcriber sampler
*/
-public class SubscriberSampler extends BaseJMSSampler implements TestListener, MessageListener {
+public class SubscriberSampler extends BaseJMSSampler implements Interruptible, TestListener, MessageListener {
private static final long serialVersionUID = 233L;
@@ -52,6 +53,9 @@
//@GuardedBy("this")
private transient int counter = 0;
+
+ //@GuardedBy("this")
+ private boolean interrupted = false;
// Don't change the string, as it is used in JMX files
private static final String CLIENT_CHOICE = "jms.client_choice"; // $NON-NLS-1$
@@ -93,6 +97,7 @@
*
*/
private OnMessageSubscriber initListenerClient() {
+ interrupted = false;
OnMessageSubscriber sub = (OnMessageSubscriber) ClientPool.get(this);
if (sub == null) {
sub = new OnMessageSubscriber(this.getUseJNDIPropertiesAsBoolean(), this.getJNDIInitialContextFactory(),
@@ -112,6 +117,7 @@
* Create the ReceiveSubscriber client for the sampler.
*/
private void initReceiveClient() {
+ interrupted = false;
this.SUBSCRIBER = new ReceiveSubscriber(this.getUseJNDIPropertiesAsBoolean(), this
.getJNDIInitialContextFactory(), this.getProviderUrl(), this.getConnectionFactory(), this.getTopic(),
this.isUseAuth(), this.getUsername(), this.getPassword());
@@ -148,7 +154,7 @@
int loop = this.getIterationCount();
result.sampleStart();
- while (this.count(0) < loop) {
+ while (this.count(0) < loop && interrupted == false) {
try {
Thread.sleep(0, 50);
} catch (InterruptedException e) {
@@ -190,7 +196,7 @@
this.SUBSCRIBER.setLoop(loop);
result.sampleStart();
- while (this.SUBSCRIBER.count(0) < loop) {
+ while (this.SUBSCRIBER.count(0) < loop && interrupted == false) {
try {
Thread.sleep(0, 50);
} catch (InterruptedException e) {
@@ -276,6 +282,18 @@
}
return choice;
}
+
+ /**
+ * Handle an interrupt of the test.
+ */
+ public boolean interrupt() {
+ interrupted = true; // so we break the loops in SampleWithListener and SampleWithReceive
+ log.debug("SubscribertSampler.interrupt called");
+ ClientPool.clearClient();
+ this.SUBSCRIBER = null;
+ this.resetCount();
+ return true;
+ }
// This was the old value that was checked for
private final static String RECEIVE_STR = JMeterUtils.getResString(JMSSubscriberGui.RECEIVE_RSC); // $NON-NLS-1$
} |
Sebb (migrated from Bugzilla): I had to change the interrupted boolean flag to volatile, else the updated value might not be propagated to the running thread. Also, the interrupt() method should not clear down the pool or counts. URL: http://svn.apache.org/viewvc?rev=832426&view=rev |
Hiskill (Bug 47900):
I have threads configured with one Subscriber and one Publisher to run 10 times for JMS topic tests. Publisher thread seems to be stopped at the end of test where as Subscriber thread seems to be still running, I can't stop it from the menu option either, here is the log:
2009/09/24 11:12:18 INFO - jmeter.threads.JMeterThread: Thread finished: Publisher 2-1
2009/09/24 11:12:18 INFO - jmeter.engine.StandardJMeterEngine: Ending thread Publisher 2-1
2009/09/24 11:13:52 INFO - jmeter.gui.action.Start: Stopping test
2009/09/24 11:13:52 INFO - jmeter.threads.JMeterThread: Stopping: Subscribers 1-1
2009/09/24 11:13:52 WARN - jmeter.threads.JMeterThread: Sampler is not Interruptible: Subscriber
2009/09/24 11:13:57 WARN - jmeter.engine.StandardJMeterEngine: Thread won't exit: Subscribers 1-1
2009/09/24 11:13:57 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test
2009/09/24 11:13:57 INFO - jmeter.protocol.jms.client.Publisher: Publisher closed
2009/09/24 11:13:57 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(false,local)
2009/09/24 11:13:57 INFO - jmeter.engine.StandardJMeterEngine: Test has ended
Severity: normal
OS: All
The text was updated successfully, but these errors were encountered: