[jboss-cvs] jboss-seam/src/main/org/jboss/seam/remoting/messaging ...
Shane Bryzak
Shane_Bryzak at symantec.com
Sun Oct 8 07:24:48 EDT 2006
User: sbryzak2
Date: 06/10/08 07:24:48
Modified: src/main/org/jboss/seam/remoting/messaging
PollRequest.java RemoteSubscriber.java
SubscriptionRegistry.java
Log:
Improved JMS exception handling
Revision Changes Path
1.4 +23 -2 jboss-seam/src/main/org/jboss/seam/remoting/messaging/PollRequest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PollRequest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/remoting/messaging/PollRequest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- PollRequest.java 25 Mar 2006 05:08:46 -0000 1.3
+++ PollRequest.java 8 Oct 2006 11:24:48 -0000 1.4
@@ -1,10 +1,12 @@
package org.jboss.seam.remoting.messaging;
+import java.util.ArrayList;
import java.util.List;
-
import javax.jms.Message;
+import javax.jms.*;
/**
+ * Wrapper for a single request for a specified subscription poll.
*
* @author Shane Bryzak
*/
@@ -13,6 +15,7 @@
private String token;
private int timeout;
private List<Message> messages;
+ private List<PollError> errors = new ArrayList<PollError>();
public PollRequest(String token, int timeout)
{
@@ -30,10 +33,28 @@
return messages;
}
+ public List<PollError> getErrors()
+ {
+ return errors;
+ }
+
public void poll()
{
RemoteSubscriber subscriber = SubscriptionRegistry.instance().getSubscription(token);
if (subscriber != null)
+ {
+ try
+ {
messages = subscriber.poll(timeout);
}
+ catch (JMSException ex)
+ {
+ errors.add(new PollError(PollError.ERROR_CODE_JMS_EXCEPTION,
+ "Error polling for messages"));
+ }
+ }
+ else
+ errors.add(new PollError(PollError.ERROR_CODE_TOKEN_NOT_FOUND,
+ "No subscription was found for the specified token."));
+ }
}
1.5 +6 -9 jboss-seam/src/main/org/jboss/seam/remoting/messaging/RemoteSubscriber.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RemoteSubscriber.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/remoting/messaging/RemoteSubscriber.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- RemoteSubscriber.java 7 Jun 2006 03:31:57 -0000 1.4
+++ RemoteSubscriber.java 8 Oct 2006 11:24:48 -0000 1.5
@@ -74,6 +74,7 @@
}
public List<Message> poll(int timeout)
+ throws JMSException
{
List<Message> messages = null;
@@ -82,16 +83,12 @@
synchronized(subscriber)
{
do {
- try {
// Only timeout for the first message.. subsequent messages should be nowait
if (messages == null && timeout > 0)
m = subscriber.receive(timeout * 1000);
else
m = subscriber.receiveNoWait();
- }
- catch (JMSException ex) {
- ex.printStackTrace();
- }
+
if (m != null) {
if (messages == null)
messages = new ArrayList<Message> ();
1.7 +9 -0 jboss-seam/src/main/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SubscriptionRegistry.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- SubscriptionRegistry.java 7 Jun 2006 22:10:28 -0000 1.6
+++ SubscriptionRegistry.java 8 Oct 2006 11:24:48 -0000 1.7
@@ -17,6 +17,8 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.contexts.Context;
import org.jboss.seam.contexts.Contexts;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
/**
*
@@ -90,6 +92,13 @@
Class providerClass = Class.forName(providerName);
JMSConnectionProvider provider = (JMSConnectionProvider) providerClass.newInstance();
topicConnection = provider.createConnection();
+
+ topicConnection.setExceptionListener(new ExceptionListener() {
+ public void onException(JMSException ex)
+ {
+ // swallow the exception for now - do we need to try and reconnect???
+ }
+ });
topicConnection.start();
}
catch (ClassNotFoundException ex)
More information about the jboss-cvs-commits
mailing list