Lines 22-27
Link Here
|
22 |
import javax.jms.MessageListener; |
22 |
import javax.jms.MessageListener; |
23 |
import javax.jms.TextMessage; |
23 |
import javax.jms.TextMessage; |
24 |
|
24 |
|
|
|
25 |
import org.apache.jmeter.samplers.Interruptible; |
25 |
import org.apache.jmeter.samplers.SampleResult; |
26 |
import org.apache.jmeter.samplers.SampleResult; |
26 |
import org.apache.jmeter.testelement.TestListener; |
27 |
import org.apache.jmeter.testelement.TestListener; |
27 |
import org.apache.jmeter.util.JMeterUtils; |
28 |
import org.apache.jmeter.util.JMeterUtils; |
Lines 38-44
Link Here
|
38 |
/** |
39 |
/** |
39 |
* This class implements the JMS Subcriber sampler |
40 |
* This class implements the JMS Subcriber sampler |
40 |
*/ |
41 |
*/ |
41 |
public class SubscriberSampler extends BaseJMSSampler implements TestListener, MessageListener { |
42 |
public class SubscriberSampler extends BaseJMSSampler implements Interruptible, TestListener, MessageListener { |
42 |
|
43 |
|
43 |
private static final long serialVersionUID = 233L; |
44 |
private static final long serialVersionUID = 233L; |
44 |
|
45 |
|
Lines 52-57
Link Here
|
52 |
|
53 |
|
53 |
//@GuardedBy("this") |
54 |
//@GuardedBy("this") |
54 |
private transient int counter = 0; |
55 |
private transient int counter = 0; |
|
|
56 |
|
57 |
//@GuardedBy("this") |
58 |
private boolean interrupted = false; |
55 |
|
59 |
|
56 |
// Don't change the string, as it is used in JMX files |
60 |
// Don't change the string, as it is used in JMX files |
57 |
private static final String CLIENT_CHOICE = "jms.client_choice"; // $NON-NLS-1$ |
61 |
private static final String CLIENT_CHOICE = "jms.client_choice"; // $NON-NLS-1$ |
Lines 93-98
Link Here
|
93 |
* |
97 |
* |
94 |
*/ |
98 |
*/ |
95 |
private OnMessageSubscriber initListenerClient() { |
99 |
private OnMessageSubscriber initListenerClient() { |
|
|
100 |
interrupted = false; |
96 |
OnMessageSubscriber sub = (OnMessageSubscriber) ClientPool.get(this); |
101 |
OnMessageSubscriber sub = (OnMessageSubscriber) ClientPool.get(this); |
97 |
if (sub == null) { |
102 |
if (sub == null) { |
98 |
sub = new OnMessageSubscriber(this.getUseJNDIPropertiesAsBoolean(), this.getJNDIInitialContextFactory(), |
103 |
sub = new OnMessageSubscriber(this.getUseJNDIPropertiesAsBoolean(), this.getJNDIInitialContextFactory(), |
Lines 112-117
Link Here
|
112 |
* Create the ReceiveSubscriber client for the sampler. |
117 |
* Create the ReceiveSubscriber client for the sampler. |
113 |
*/ |
118 |
*/ |
114 |
private void initReceiveClient() { |
119 |
private void initReceiveClient() { |
|
|
120 |
interrupted = false; |
115 |
this.SUBSCRIBER = new ReceiveSubscriber(this.getUseJNDIPropertiesAsBoolean(), this |
121 |
this.SUBSCRIBER = new ReceiveSubscriber(this.getUseJNDIPropertiesAsBoolean(), this |
116 |
.getJNDIInitialContextFactory(), this.getProviderUrl(), this.getConnectionFactory(), this.getTopic(), |
122 |
.getJNDIInitialContextFactory(), this.getProviderUrl(), this.getConnectionFactory(), this.getTopic(), |
117 |
this.isUseAuth(), this.getUsername(), this.getPassword()); |
123 |
this.isUseAuth(), this.getUsername(), this.getPassword()); |
Lines 148-154
Link Here
|
148 |
int loop = this.getIterationCount(); |
154 |
int loop = this.getIterationCount(); |
149 |
|
155 |
|
150 |
result.sampleStart(); |
156 |
result.sampleStart(); |
151 |
while (this.count(0) < loop) { |
157 |
while (this.count(0) < loop && interrupted == false) { |
152 |
try { |
158 |
try { |
153 |
Thread.sleep(0, 50); |
159 |
Thread.sleep(0, 50); |
154 |
} catch (InterruptedException e) { |
160 |
} catch (InterruptedException e) { |
Lines 190-196
Link Here
|
190 |
this.SUBSCRIBER.setLoop(loop); |
196 |
this.SUBSCRIBER.setLoop(loop); |
191 |
|
197 |
|
192 |
result.sampleStart(); |
198 |
result.sampleStart(); |
193 |
while (this.SUBSCRIBER.count(0) < loop) { |
199 |
while (this.SUBSCRIBER.count(0) < loop && interrupted == false) { |
194 |
try { |
200 |
try { |
195 |
Thread.sleep(0, 50); |
201 |
Thread.sleep(0, 50); |
196 |
} catch (InterruptedException e) { |
202 |
} catch (InterruptedException e) { |
Lines 276-281
Link Here
|
276 |
} |
282 |
} |
277 |
return choice; |
283 |
return choice; |
278 |
} |
284 |
} |
|
|
285 |
|
286 |
/** |
287 |
* Handle an interrupt of the test. |
288 |
*/ |
289 |
public boolean interrupt() { |
290 |
interrupted = true; // so we break the loops in SampleWithListener and SampleWithReceive |
291 |
log.debug("SubscribertSampler.interrupt called"); |
292 |
ClientPool.clearClient(); |
293 |
this.SUBSCRIBER = null; |
294 |
this.resetCount(); |
295 |
return true; |
296 |
} |
279 |
// This was the old value that was checked for |
297 |
// This was the old value that was checked for |
280 |
private final static String RECEIVE_STR = JMeterUtils.getResString(JMSSubscriberGui.RECEIVE_RSC); // $NON-NLS-1$ |
298 |
private final static String RECEIVE_STR = JMeterUtils.getResString(JMSSubscriberGui.RECEIVE_RSC); // $NON-NLS-1$ |
281 |
} |
299 |
} |