activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r382934 - in /incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra: MessageEndpointProxy.java ServerSessionPoolImpl.java
Date Fri, 03 Mar 2006 21:24:35 GMT
Author: chirino
Date: Fri Mar  3 13:24:33 2006
New Revision: 382934

URL: http://svn.apache.org/viewcvs?rev=382934&view=rev
Log:
http://jira.activemq.org/jira/browse/AMQ-612
http://jira.activemq.org/jira/browse/AMQ-613

Modified:
    incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java
    incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java

Modified: incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java?rev=382934&r1=382933&r2=382934&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java
(original)
+++ incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java
Fri Mar  3 13:24:33 2006
@@ -29,14 +29,14 @@
 public class MessageEndpointProxy implements MessageListener, MessageEndpoint {
     
     private static final MessageEndpointState ALIVE = new MessageEndpointAlive();
-    private static final MessageEndpointState GOING_TO_DIE = new MessageEndpointInTheElectricChair();
     private static final MessageEndpointState DEAD = new MessageEndpointDead();
     
     
     private static int proxyCount = 0;    
     private final int proxyID;
     
-    private MessageEndpoint endpoint;    
+    private final MessageEndpoint endpoint;
+    private final MessageListener messageListener;
     private MessageEndpointState state = ALIVE;
 
     private static int getID() {
@@ -47,6 +47,7 @@
         if (!(endpoint instanceof MessageListener)) {
             throw new IllegalArgumentException("MessageEndpoint is not a MessageListener");
           
         }        
+        messageListener = (MessageListener) endpoint;
         proxyID = getID();
         this.endpoint = endpoint;
     }
@@ -56,7 +57,6 @@
     }
 
     public void onMessage(Message message) {
-//        log.warn("Delivery Count: " + getNextDeliveryCount() );
         state.onMessage(this, message);
     }
 
@@ -117,12 +117,7 @@
         }
 
         public void onMessage(MessageEndpointProxy proxy, Message message) {
-            try {
-                ((MessageListener) proxy.endpoint).onMessage(message);
-            } catch (RuntimeException e) {
-                transition(proxy, GOING_TO_DIE);
-                throw e;
-            }            
+            proxy.messageListener.onMessage(message);
         }
 
         public void afterDelivery(MessageEndpointProxy proxy) throws ResourceException {
@@ -139,28 +134,10 @@
         }
     }
 
-    private static class MessageEndpointInTheElectricChair extends MessageEndpointState {
-
-        public void afterDelivery(MessageEndpointProxy proxy) throws ResourceException {
-            try {
-                proxy.endpoint.afterDelivery();
-            } catch (ResourceException e) {
-                throw e;
-            } finally {
-                transition(proxy, DEAD);                
-            }
-        }
-
-        public void release(MessageEndpointProxy proxy) {
-            transition(proxy, DEAD);
-        }
-    }
-
     private static class MessageEndpointDead extends MessageEndpointState {
 
         protected void enter(MessageEndpointProxy proxy) {
             proxy.endpoint.release();
-            proxy.endpoint = null;
         }
 
         public void beforeDelivery(MessageEndpointProxy proxy, Method method) throws NoSuchMethodException,
ResourceException {

Modified: incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java?rev=382934&r1=382933&r2=382934&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java
(original)
+++ incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java
Fri Mar  3 13:24:33 2006
@@ -76,6 +76,7 @@
         } catch (UnavailableException e) {
             // The container could be limiting us on the number of endpoints
             // that are being created.
+            log.debug("Could not create an endpoint.", e);
             session.close();
             return null;
         }
@@ -104,15 +105,19 @@
         } else {
             // Are we at the upper limit?
             if (activeSessions.size() >= maxSessions) {
-                // then reuse the allready created sessions..
+                // then reuse the already created sessions..
                 // This is going to queue up messages into a session for
                 // processing.
                 return getExistingServerSession();
             }
             ServerSessionImpl ss = createServerSessionImpl();
-            // We may not be able to create a session due to the conatiner
+            // We may not be able to create a session due to the container
             // restricting us.
             if (ss == null) {
+                if (idleSessions.size() == 0) {
+                    throw new JMSException("Endpoint factory did not allows to any endpoints.");
+                }
+
                 return getExistingServerSession();
             }
             activeSessions.addLast(ss);



Mime
View raw message