activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TOPPER_HARLEY <TREVOR.HIGG...@ERICSSON.COM>
Subject Temp queue deleted when thread interrupted
Date Thu, 06 Sep 2007 17:20:19 GMT

Hi all,
This is a follow on from the thread "Temp queue vs topic with message
selectors?", where I was having difficulty with temp queues. 

See also :  https://issues.apache.org/activemq/browse/AMQ-1375 AMQ-1375 

Anyway,  following some investigation I have encountered a situation where
temp queues are deleted by AMQ incorrectly(I think anyway)......it happens
if you interrupt the thread that is calling 

      producer.send(message);

, and in the same thread call this method again, AMQ then deletes the temp
queue. It is reproducible and I have attached a java project containing all
required info. Required jars are 
1) apache-activemq-4.1.1.jar
2) spring.jar (version 2.0.2 I had) 
3) xbean-spring-2.8.jar
4) junit.jar

Main class is AMQTest, which is a Junit test. 

My setup is as follows:

1) Embedded broker on server side AMQ 4.1.1
2) One client, it creates a temp queue and requests server to send data back
on it. This is implemented as a Runnable submitted to an executor on the
server and generates a job ID, which is returned to the client.
3) Client asks server in a loop to send data (say 10 times, hence 10
Runnables submitted) AND cancels the last job based on the ID, hence I
should get all the messages for the last job.
4) Server task will fail to send data once it is interrupted, which is fine
but if you continue to try and send again following the first
InterruptedIOException, the temp queue is deleted. After this I dont get any
data obviously.

I have done some debugging and have found the reason for it & also how to
solve it. My activemq.xml file defines 2 transport connectors, one VM and
one TCP. My server side connection factory uses the VM URL for its brokerURL
property. This is to save a network hop as broker is embedded. To simulate
client being in another JVM, my receiver uses TCP URL to connect to the
broker. So then when I send data, AMQ magically puts it from VM to TCP. Once
the InterruptedIOException occurs, I can still create a MessageProducer as
its only towards the VM broker, but the send of the message fails & deletes
the queue. 

The solution is to pass the TCP URL to the senderConnectionFactory as well,
which works fine, I get all the messages for the last requested job. This is
not really an issue except I lose the benefit of having an internal broker.
I would like to know if this is expected behaviour or a bug & why it is
happening?

To get the attached junit test to pass, simply change the brokerURL of the
"senderConnectionFactory" bean from 

<property name="brokerURL" value="${internal.broker.url}"/>

to
<property name="brokerURL" value="${external.broker.url}"/>

by switching the comments around in topology-test.xml.

Also attached is the print of test case failing and also where it
succeeds....if you don't wanna run it ;)

Thanks
/Tom

http://www.nabble.com/file/p12527277/AMQ_Test.zip AMQ_Test.zip 
http://www.nabble.com/file/p12527277/failed.txt failed.txt 
http://www.nabble.com/file/p12527277/succeeded.txt succeeded.txt 
-- 
View this message in context: http://www.nabble.com/Temp-queue-deleted-when-thread-interrupted-tf4393533s2354.html#a12527277
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message