我们使用HornetQ 2.2.5,我们的问题是在客户端(向Q发送消息),所有生产者线程都陷入WAITING状态。
请注意,生产者位于一台机器上,而 HornetQ 服务器位于另一台机器上。
这是客户端的线程转储:
Thread: pool-10-thread-9 : priority:5, demon:false, threadId:521, threadState:WAITING, lockName:java.util.concurrent.Semaphore$NonfairSync@60568a13
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:156) java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811) java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:969) java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1281)
java.util.concurrent.Semaphore.acquire(Semaphore.java:441) org.hornetq.core.client.impl.ClientProducerCreditsImpl.acquireCredits(ClientProducerCreditsImpl.java:74) org.hornetq.core.client.impl.ClientProducerImpl.doSend(ClientProducerImpl.java:305) org.hornetq.core.client.impl.ClientProducerImpl.send(ClientProducerImpl.java:142) org.hornetq.jms.client.HornetQMessageProducer.doSend(HornetQMessageProducer.java:451) org.hornetq.jms.client.HornetQMessageProducer.send(HornetQMessageProducer.java:199)
与 Q 的连接和 session 在客户端进行缓存和重用。
在服务器端有以下日志:
[hornetq-failure-check-thread] 19:25:30,820 WARNING [org.hornetq.core.protocol.core.impl.RemotingConnectionImpl]
Connection failure has been detected: Did not receive data from /10.2.6.11:50697. It is likely the client has exited or crashed without closing its connection, or the network between the server and client has failed. You also might have configured connection-ttl and client-failure-check-period incorrectly. Please check user manual for more information. The connection will now be closed. [code=3]
是否有任何原因导致所有生产者线程都卡住?
最佳答案
这是 hornetq 用户论坛上的常见问题解答...
HornetQ 有不同的方法来处理消息溢出,防止内存不足。
- 溢出时阻止
- 流向磁盘(我们称之为分页)
- 丢弃(消息将消失。仅在您可以承受丢失消息的情况下有效)
- 错误(最近在 2.4 上引入,2.2 没有此功能)
当您将系统设置为阻止时,客户端将等待只有在您消费消息后才会到达的积分。
因此,要么使用消息,要么将地址设置设置为寻呼。
有关设置分页的文档:
http://docs.jboss.org/hornetq/2.4.0.beta1/docs/user-manual/html/paging.html#paging.main.config
有关阻塞模式的文档:
http://docs.jboss.org/hornetq/2.4.0.beta1/docs/user-manual/html/paging.html#d0e5213
关于HornetQ 生产者线程陷入 WAITING 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19816618/