Bug 778038 (SOA-563)

Summary: ESB clients hang because of JBoss Messaging background threads
Product: [JBoss] JBoss Enterprise SOA Platform 4 Reporter: Kevin Conner <kevin.conner>
Component: JBossESBAssignee: Kevin Conner <kevin.conner>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 4.2 CP02   
Target Milestone: ---   
Target Release: 4.2 CP02   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/SOA-563
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-06-10 09:25:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Kevin Conner 2008-06-09 12:32:42 UTC
Date of First Response: 2008-06-09 09:04:21
project_key: SOA

The ESB clients can hang as a result of background threads being created by JBoss Messaging.

The version of JBoss Messaging inherited from the EAP release appears to be 1.4.0.SP3-CP02.

The issue is as follows.

ESB manages the JMS sessions through a pooling mechanism, this mechanism explicitly cleans up the JMS resources using a shutdown hook.  The actual mechanism is more involved than this as it also deals with scoping all ESB resources within the app server but, for a standalone client, this is the general behaviour.

Unfortunately the specified version of JBoss Messaging is using the oswego QueuedExecutor but their factory does not explicitly set the 'daemon' attribute (either to true or false) when creating the threads.  As a consequence the thread may or may not be tagged as a daemon thread depending on which thread is being used to create the executor.

If the created thread is *not* a daemon then this will prevent the VM from closing unless the session has been explicitly closed.

This leads us very nicely into a catch-22 situation

JBM requires a close to cleanup the thread and thus enable shutdown to occur.
ESB requires the shutdown hook to execute the close on the session, when the pool is cleaned up.

The result is that the client will always hang.

A client of the FP release of SOA-P would contain the following threads prior to main exiting

Java HotSpot(TM) Server VM[localhost:8787]	
	Thread [main] (Suspended)	
	Daemon Thread [Timer-0] (Running)	
	Daemon Thread [Timer-1] (Running)	
	Daemon Thread [control: Socket[addr=/127.0.0.1,port=2995,localport=34035]] (Running)	
	Daemon Thread [Timer-2] (Running)	

whereas a client on the CP2 release contains the following threads prior to main exiting

Java HotSpot(TM) Server VM[localhost:8787]	
	Thread [main] (Suspended)	
	Daemon Thread [Timer-0] (Running)	
	Daemon Thread [Timer-1] (Running)	
	Daemon Thread [control: Socket[addr=/127.0.0.1,port=2070,localport=35190]] (Running)	
	Daemon Thread [Timer-2] (Running)	
	Thread [jbm-client-session-f2-4l4iy8hf-1-l0qey8hf-0kdngz-100j3] (Suspended)	
		java.lang.Object.wait(long) line: not available [native method]	
		java.lang.Object.wait() line: 474	
		EDU.oswego.cs.dl.util.concurrent.LinkedQueue.take() line: 122	
		EDU.oswego.cs.dl.util.concurrent.QueuedExecutor$RunLoop.run() line: 83	
		java.lang.Thread.run() line: 595	

It is the last which is preventing the VM from closing down

Comment 1 Kevin Conner 2008-06-09 12:33:39 UTC
The quickest way to handle this is, at least for ESB, is to force the JBM threads into a daemon state by creating all sessions (and therefore executors) on a daemon background thread.

Comment 2 Mark Little 2008-06-09 13:04:21 UTC
Sounds like a JBM issue to me. Can you also create a JIRA in JBM and link it here?

Comment 3 Kevin Conner 2008-06-09 14:38:32 UTC
Link: Added: This issue depends JBESB-1799


Comment 4 Jiri Pechanec 2008-06-10 09:25:42 UTC
Verified in CR1

Comment 5 Julian Coleman 2008-06-30 15:29:27 UTC
Link: Added: This issue related JBMESSAGING-1387


Comment 6 Julian Coleman 2008-06-30 15:32:29 UTC
Link: Added: This issue related JBPAPP-935


Comment 7 Julian Coleman 2011-04-07 10:25:40 UTC
Link: Added: This issue relates to SOA-3006