[seam-commits] Seam SVN: r11447 - branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Fri Aug 28 17:17:17 EDT 2009
Author: norman.richards at jboss.com
Date: 2009-08-28 17:17:16 -0400 (Fri, 28 Aug 2009)
New Revision: 11447
Modified:
branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
Log:
JBSEAM-4212
Modified: branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
===================================================================
--- branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java 2009-08-28 19:45:50 UTC (rev 11446)
+++ branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java 2009-08-28 21:17:16 UTC (rev 11447)
@@ -104,28 +104,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