[jbossseam-issues] [JBoss JIRA] Updated: (JBSEAM-2082) JMS Topic subscriptions never released

Scott McNab (JIRA) jira-events at lists.jboss.org
Tue Apr 28 04:55:46 EDT 2009


     [ https://jira.jboss.org/jira/browse/JBSEAM-2082?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Scott McNab updated JBSEAM-2082:
--------------------------------

          Environment: JBossAS 4.2.3.GA, All platforms.   (was: JBossAS 4.2.0.GA, All platforms. )
    Affects Version/s: 2.0.2.SP1


We have (finally!) developed a workaround to this problem: it involves extending the SeamListener to unsubscribe any JMS subscribers that are still active whenever a Session is destroyed. This way we can guarantee that all Seam JMS sessions are eventually closed when they are no longer in use.

The code for our custom SeamListener class is as follows (we also modify the web.xml to use our custom listener instead of the standard one):

public class CustomSeamListener extends SeamListener {
	@Override
	public void sessionDestroyed(HttpSessionEvent event)  {
		// Fake a HttpServletRequest that unsubscribes all the tokens associated with this session
		HttpServletRequest req = new MockHttpServletRequest(event.getSession());
		ServletLifecycle.beginRequest(req);
		ServletContexts.instance().setRequest(req);
		
		// Take a copy of the token list so we don't modify the list as we are iterating
		SubscriptionRegistry subRegistry = SubscriptionRegistry.instance();
		Set<String> tokenSet = new HashSet<String>();
		tokenSet.addAll(subRegistry.getUserTokens());

		// Unsubscribe all the subscriptions associated with this session
		for (String token : tokenSet) {
			RemoteSubscriber subscriber = subRegistry.getSubscription(token);
			subscriber.unsubscribe();
		}
		ServletLifecycle.endRequest(req);
		
		// Call the normal SeamListener implementation
		super.sessionDestroyed(event);	
	 }
}

Can we please get a comment on the validity of this workaround? (Specifically, is there a better way to access the SubscriptionRegistry other than using the MockHttpServletRequest like this?)

Also, if this is indeed a valid fix, could we please get it integrated into the official SeamListener source code?

Thanks
Scott

> JMS Topic subscriptions never released
> --------------------------------------
>
>                 Key: JBSEAM-2082
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-2082
>             Project: Seam
>          Issue Type: Bug
>          Components: Remoting
>    Affects Versions: 1.2.0.GA, 1.2.1.GA, 2.0.0.CR1, 2.0.0.CR2, 2.0.0.CR3, 2.0.2.SP1
>         Environment: JBossAS 4.2.3.GA, All platforms. 
>            Reporter: Scott McNab
>            Assignee: Shane Bryzak
>
> In the current Seam remoting implementation, there is no mechanism to clean up and release JMS topic subscriptions for clients that may have subscribed to a JMS topic, but who do not explicitly unsubscribe()  (e.g. due to a coding error or if the client simply disappears)
> Unless a web-client specifically calls Seam.Remoting.unsubscribe(), the RemoteSubscriber object is never released, and the corresponding TopicSession and TopicSubscriber resources will be held open indefinitely. This will cause the JMS provider to store an ever-growing list of undelivered topic messages, which will eventually result in an out of memory crash.
> Seam Remoting needs to be able to correctly identify situations whereby a RemoteSubscriber is no longer in use, and release resources accordingly.
> One possible solution might be to periodically check all subscriptions in the SubscriptionRegistry and release any which have not had a recent poll request beyond a certain time limit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list