The problem of ACTIVEMQ deadlock

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.