今天在用mule与activeMQ集成时,启动mule时总停留在activeMQ的启动那里。经过查看源代码发现activeMQ里面出现了一个死循环。
protected void lock() throws Exception {
lockLogged = false;
lockAquired = false;
do {
if (doLock()) {
lockAquired = true;
} else {
if (!lockLogged) {
LOG.warn("Waiting to Lock the Store " + getDirectory());
lockLogged = true;
}
Thread.sleep(1000);
}
} while (!lockAquired && !disableLocking);
}
protected boolean doLock() throws IOException {
boolean result = true;
if (!disableLocking && directory != null && lock == null) {
String key = getPropertyKey();
String property = System.getProperty(key);
if (null == property) {
if (!BROKEN_FILE_LOCK) {
lock = lockFile.getChannel().tryLock();
if (lock == null) {
result = false;
} else {
System.setProperty(key, new Date().toString());
}
}
} else { // already locked
result = false;
}
}
return result;
}
在上面的代码中,dolock返回的始终是false。然后你就可以看到lock()方法就成了一个死循环了。不知道这是activeMQ的问题还是我自己哪里出错。
配置如下:
<amq:broker useJmx="false" persistent="true">
<amq:persistenceAdapter>
<amq:amqPersistenceAdapter directory="e:/amq" />
</amq:persistenceAdapter>
<amq:transportConnectors>
<amq:transportConnector uri="tcp://192.168.103.74:61616" />
</amq:transportConnectors>
</amq:broker>
最后实在无奈,只好去掉持久化,改成persistent为false。
<amq:broker useJmx="false" persistent="false">
<!-- <amq:persistenceAdapter>
<amq:amqPersistenceAdapter directory="e:/amq" />
</amq:persistenceAdapter> -->
<amq:transportConnectors>
<amq:transportConnector uri="tcp://192.168.103.74:61616" />
</amq:transportConnectors>
</amq:broker>