In the development process encountered a activemq deadlock problem, painful experience:
scenario: background processes (Appserver1) constantly generate tasks, send to queue front application (appservers) requests, get messages to the queue, and retrieve corresponding data according to the message.
question:
multithreading to the same queue directly call receive, receive messages, the queue will be locked:
The information on the server side dump is as follows:
Ound One java-level deadlock: ============================= "tcp:///10.0.72.76:52012": Waiting to lock monitor 0x080ead4c (Object 0x952b6950, a java.util.LinkedList), Which is held by "tcp:///10.0.72.76:52010" "tcp:///10.0.72.76:52010": Waiting to lock monitor 0x080ead8c (Object 0x8e7f6620, a org.apache.activemq.broker.region.QueueSubscription), Which is held by "tcp:///10.0.72.76:52012" |
in the ACTIVEMQ forum found the following content patch:
In the 4.1 and previous versions, you need to modify the source code in the following ways
Index:activemq-core/src/main/java/org/apache/activemq/activemqsessionexecutor.java =================================================================== ---activemq-core/src/main/java/org/apache/activemq/activemqsessionexecutor.java (revision 480716) +++ Activemq-core/src/main/java/org/apache/activemq/activemqsessionexecutor.java (revision 480717) @@ -63,8 +63,11 @@
public void Wakeup () { if (!dispatchedbysessionpool) { -if (taskrunner!=null) { + if (Session.issessionasyncdispatch ()) { try { + if (Taskrunner = null) { + Taskrunner =session.connection.getsessiontaskrunner (). Createtaskrunner (This, "ActiveMQ session:" +s Ession.getsessionid ()); + } Taskrunner.wakeup (); catch (Interruptedexception e) { Thread.CurrentThread (). interrupt (); @@ -101,10 +104,8 @@ synchronized void Start () { if (!messagequeue.isrunning ()) { Messagequeue.start (); -if (Session.issessionasyncdispatch () | | dispatchedbysessionpool) { -Taskrunner =session.connection.getsessiontaskrunner (). Createtaskrunner (This, "ActiveMQ session:" +SESSION.G Etsessionid ()); - } -Wakeup (); + if (hasuncomsumedmessages ()) + Wakeup (); } }
|
The problem has been resolved in 4.1.1 and 4.2, although none of the two versions are available yet. Be careful with the ACTIVEMQ students.