我們使用MessagePack 0.6.6
對Java Grails的2.0
在WebLogic11克(10.3)
序列化字符串數據...MessagePack模板查找導致WebLogic中卡住線程?
public void serialize(Object object, OutputStream outputStream)
throws IOException {
byte[] bytes = MessagePack.pack(object);
outputStream.write(bytes);
outputStream.flush();
}
我們在WebLogic中看到的問題是,大量阻塞線程的,所以我們向線程並發現一些線程卡在org.msgpack.template.TemplateRegistry.lookup(TemplateRegistry:198)
,請參閱下面的轉儲。我們確信我們的代碼沒有引入這個問題,因爲在上面的例子中,我們很清楚我們以線程安全的方式使用了MessagePack.pack()
。看着 TemplateRegistry.java, line 198,lookup()
是同步的,但我們不確定它爲什麼導致卡住的線程。
"[STUCK] ExecuteThread:
'1' for queue: 'weblogic.kernel.Default (self-tuning)'" id=43 idx=0xec tid=60 prio=1 alive, in native, blocked, daemon
-- Blocked trying to get lock: org/msgpack/template/[email protected][fat lock]
at jrockit/vm/Threads.waitForUnblockSignal()V(Native Method)
at jrockit/vm/Locks.fatLockBlockOrSpin(Locks.java:1679)[optimized]
at jrockit/vm/Locks.lockFat(Locks.java:1780)[optimized]
at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1312)[optimized]
at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1259)[optimized]
at jrockit/vm/Locks.monitorEnter(Locks.java:2466)[inlined]
at jrockit/vm/Locks.monitorEnterForced(Locks.java:859)[optimized]
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
at jrockit/vm/Locks.monitorEnterUnmatched(Ljava/lang/Object;)V(Native Method)
at org/msgpack/template/TemplateRegistry.lookup(TemplateRegistry.java:198)[optimized]
at org/msgpack/MessagePack.write(MessagePack.java:195)[inlined]
at org/msgpack/MessagePack.pack(MessagePack.java:639)[inlined]
看到李的回答,這是正確的。 – raffian
@raffian我部分同意Lee的觀點,我只是聲稱在最新的消息包版本中,當您調用新的MessagePack()。write(someObject)方法時,默認情況下會創建新的消息包裝器,因此您不必顯式創建它足以在MessagePack實例上調用寫入方法。請檢查源代碼,如果您不同意此聲明,請告訴我我錯在哪裏。 – abovesun
我相信你,我沒有說你錯了,只是說李的回答對我原來的問題已經足夠了。 – raffian