[seam-commits] Seam SVN: r11478 - branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Fri Sep 11 07:35:28 EDT 2009
Author: manaRH
Date: 2009-09-11 07:35:28 -0400 (Fri, 11 Sep 2009)
New Revision: 11478
Modified:
branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
Log:
JBPAPP-2737
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java 2009-09-11 10:39:24 UTC (rev 11477)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java 2009-09-11 11:35:28 UTC (rev 11478)
@@ -18,8 +18,6 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Context;
-import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.util.Reflections;
@@ -131,28 +129,60 @@
public RemoteSubscriber subscribe(String topicName)
{
- if (!allowedTopics.contains(topicName))
+ if (!allowedTopics.contains(topicName)) {
throw new IllegalArgumentException(String.format(
"Cannot subscribe to a topic that is not allowed. Topic [%s] is not an " +
"allowed topic.", topicName));
+ }
RemoteSubscriber sub = new RemoteSubscriber(UUID.randomUUID().toString(), topicName);
try {
- sub.subscribe(getTopicConnection());
+ subscribe(sub);
subscriptions.put(sub.getToken(), sub);
// Save the client's token in their session context
getUserTokens().add(sub.getToken());
return sub;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
log.error(ex);
return null;
}
}
+ private void subscribe(RemoteSubscriber sub)
+ throws JMSException, Exception
+ {
+ try {
+ sub.subscribe(getTopicConnection());
+ } catch (Exception e) {
+ log.debug(e);
+
+ // Clear the topic connection and try again.
+ resetTopic();
+ sub.subscribe(getTopicConnection());
+ }
+ }
+
+ private void resetTopic()
+ {
+ TopicConnection savedTopic = null;
+
+ synchronized(monitor) {
+ if (topicConnection != null) {
+ savedTopic = topicConnection;
+ topicConnection = null;
+ }
+ }
+
+ if (savedTopic != null) {
+ try {
+ savedTopic.close();
+ } catch (Exception ignored) { }
+ }
+ }
+
public UserTokens getUserTokens()
{
return (UserTokens) Component.getInstance(UserTokens.class);
More information about the seam-commits
mailing list