[seam-commits] Seam SVN: r12608 - branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/messaging.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Fri Apr 23 09:27:57 EDT 2010
Author: manaRH
Date: 2010-04-23 09:27:56 -0400 (Fri, 23 Apr 2010)
New Revision: 12608
Modified:
branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
Log:
JBSEAM-4212
Modified: branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java 2010-04-23 13:07:16 UTC (rev 12607)
+++ branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java 2010-04-23 13:27:56 UTC (rev 12608)
@@ -105,14 +105,16 @@
public RemoteSubscriber subscribe(String 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
@@ -125,6 +127,46 @@
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()
{
More information about the seam-commits
mailing list