11 Replies Latest reply: Mar 19, 2012 11:19 PM by freeliuade freeliuade RSS

meet hang on call a ejb, add a timeout property in jboss-server.xml?

freeliuade freeliuade Newbie

Hi,

I'm doing a nagative case for my application, a client to call a ejb server. (client and server is on different machine), when ejb call reach server side, unplug the server machine network. (by using debug to suspend server side to know the ejb server is on processing client call)

 

client will wait forever. following is the client side thread dump, block at java.net.SocketInputStream.socketRead0(Native Method), and I debugged it, the timeout value send to native api is 0, means never timeout.

 

C:\Documents and Settings\hyliu>jstack 18320
2011-12-28 14:32:26
Full thread dump Java HotSpot(TM) Client VM (17.0-b17 mixed mode):

"RMI RenewClean-[pek-wkst71btb:1101]" daemon prio=6 tid=0x171ec000 nid=0x19f0 in Object.wait() [0x17
3af000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x02eb00d0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
        - locked <0x02eb00d0> (a java.lang.ref.ReferenceQueue$Lock)
        at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(DGCClient.java:516)
        at java.lang.Thread.run(Thread.java:619)

"RMI Scheduler(0)" daemon prio=6 tid=0x171ddc00 nid=0x4070 waiting on condition [0x1735f000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x07f746b0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
        at java.util.concurrent.DelayQueue.take(DelayQueue.java:160)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:583)
        at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:576)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)

"GC Daemon" daemon prio=2 tid=0x171da400 nid=0x43c4 in Object.wait() [0x1730f000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x07f74038> (a sun.misc.GC$LatencyLock)
        at sun.misc.GC$Daemon.run(GC.java:100)
        - locked <0x07f74038> (a sun.misc.GC$LatencyLock)

"RMI RenewClean-[pek-wkst2cwxc:1101]" daemon prio=6 tid=0x171d9800 nid=0x471c in Object.wait() [0x17
2bf000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x07f73cb0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
        - locked <0x07f73cb0> (a java.lang.ref.ReferenceQueue$Lock)
        at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(DGCClient.java:516)
        at java.lang.Thread.run(Thread.java:619)

"Low Memory Detector" daemon prio=6 tid=0x16bc8400 nid=0x3c78 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x16bb2000 nid=0x2090 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"JDWP Command Reader" daemon prio=6 tid=0x16baec00 nid=0x45b4 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"JDWP Event Helper Thread" daemon prio=6 tid=0x16bad400 nid=0x2bb0 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"JDWP Transport Listener: dt_socket" daemon prio=6 tid=0x16baa800 nid=0x26c0 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Attach Listener" daemon prio=10 tid=0x16b9a800 nid=0x4704 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x16b99400 nid=0x403c runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x16b89000 nid=0x3cbc in Object.wait() [0x16cff000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x07f20a30> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
        - locked <0x07f20a30> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x16b84400 nid=0x40f8 in Object.wait() [0x16caf000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x07f20958> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:485)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0x07f20958> (a java.lang.ref.Reference$Lock)

"main" prio=6 tid=0x00847800 nid=0x449c runnable [0x0091f000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
        - locked <0x02afb570> (a java.io.BufferedInputStream)
        at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2249)
        at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:242
9)
        at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2499)
        at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2571)
        at java.io.ObjectInputStream.read(ObjectInputStream.java:820)
        at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.readVersion(MicroSocketClientInvoker.java:1000)
        at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:574)
        at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
        at org.jboss.remoting.Client.invoke(Client.java:1634)
        at org.jboss.remoting.Client.invoke(Client.java:548)
        at org.jboss.invocation.unified.interfaces.UnifiedInvokerHAProxy.invoke(UnifiedInvokerHAProxy.java:188)
        at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
        at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
        at org.jboss.proxy.ejb.RetryInterceptor.invoke(RetryInterceptor.java:176)
        at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
        at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
        at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:112)
        at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
        at $Proxy2.getDomainInfo(Unknown Source)
        at com.qilin.EJBLookupTest.lookupEJB(EJBLookupTest.java:78)
        at com.qilin.EJBLookupTest.lookup(EJBLookupTest.java:58)
        at com.qilin.EJBLookupTest.main(EJBLookupTest.java:33)

"VM Thread" prio=10 tid=0x16b81c00 nid=0x43c8 runnable

"VM Periodic Task Thread" prio=10 tid=0x16bca000 nid=0x4314 waiting on condition

JNI global references: 2172

 

 

and after some google search, add a timeout property (blue part) in server side jboss-service.xml can get a timeout. and tried it works

 

               <!-- The following are specific to socket invoker -->

               <!-- <attribute name="numAcceptThreads">1</attribute>-->

               <!-- <attribute name="maxPoolSize">303</attribute>-->

               <!-- <attribute name="clientMaxPoolSize" isParam="true">304</attribute>-->

               <attribute name="timeout" isParam="true">600000</attribute>

               <attribute name="socketTimeout" isParam="true">600000</attribute>

               <attribute name="serverBindAddress">${jboss.bind.address}</attribute>

               <attribute name="serverBindPort">4446</attribute>

               <!-- <attribute name="clientConnectAddress">216.23.33.2</attribute> -->

               <!-- <attribute name="clientConnectPort">7777</attribute> -->

 

My question are:

1. is it a right way to add this timeout. what's any side effect?

2. why jboss hasn't a default timeout value for this?

 

BTW, the ejb is a cluster ejb, have multiple nodes run on server side. unpluged one of nodes's network when using debug to get the client call is load balanced to this node.

 

jboss version is 4.2.2GA