activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r787432 - /activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java
Date Mon, 22 Jun 2009 22:55:55 GMT
Author: chirino
Date: Mon Jun 22 22:55:55 2009
New Revision: 787432

URL: http://svn.apache.org/viewvc?rev=787432&view=rev
Log:
Adding the default session.. Makes the JmsRedeliveredTest test happier.

Modified:
    activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java

Modified: activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java?rev=787432&r1=787431&r2=787432&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-openwire/src/main/java/org/apache/activemq/broker/openwire/OpenwireProtocolHandler.java
Mon Jun 22 22:55:55 2009
@@ -21,7 +21,6 @@
 import java.util.HashMap;
 import java.util.LinkedList;
 
-import org.apache.activemq.Service;
 import org.apache.activemq.apollo.WindowLimiter;
 import org.apache.activemq.apollo.broker.Broker;
 import org.apache.activemq.apollo.broker.BrokerConnection;
@@ -71,7 +70,6 @@
 import org.apache.activemq.filter.FilterException;
 import org.apache.activemq.filter.LogicExpression;
 import org.apache.activemq.filter.NoLocalExpression;
-import org.apache.activemq.flow.AbstractLimitedFlowResource;
 import org.apache.activemq.flow.Flow;
 import org.apache.activemq.flow.FlowController;
 import org.apache.activemq.flow.IFlowController;
@@ -125,33 +123,38 @@
                         }
                     };
                     connections.put(info.getConnectionId(), connection);
+                    
+                    // Connections have an implicitly created "default" session identified
by session id = -1
+                    SessionId sessionId = new SessionId(info.getConnectionId(), -1);
+                    addSession(sessionId, connection);
                 }
                 return ack(info);
             }
 
             public Response processAddSession(final SessionInfo info) throws Exception {
-                ClientContext connection = connections.get(info.getSessionId().getParentId());
+                final SessionId sessionId = info.getSessionId();
+                ClientContext connection = connections.get(sessionId.getParentId());
                 if (connection == null) {
-                    throw new IllegalStateException(host.getHostName() + " Cannot add a session
to a connection that had not been registered: " + info.getSessionId().getParentId());
+                    throw new IllegalStateException(host.getHostName() + " Cannot add a session
to a connection that had not been registered: " + sessionId.getParentId());
                 }
 
-                if (!sessions.containsKey(info.getSessionId())) {
-
-                    ClientContext session = new AbstractClientContext<MessageDelivery>(info.getSessionId().toString(),
connection) {
-                        SessionInfo sessioninfo = info;
-
-                        public void close() {
-                            super.close();
-                            sessions.remove(sessioninfo.getSessionId());
-                        }
-                    };
-
-                    sessions.put(info.getSessionId(), session);
+                if (!sessions.containsKey(sessionId)) {
+                    addSession(sessionId, connection);
                 }
 
                 return ack(info);
             }
 
+            private void addSession(final SessionId sessionId, ClientContext connection)
{
+                ClientContext session = new AbstractClientContext<MessageDelivery>(sessionId.toString(),
connection) {
+                    public void close() {
+                        super.close();
+                        sessions.remove(sessionId);
+                    }
+                };
+                sessions.put(sessionId, session);
+            }
+
             public Response processAddProducer(ProducerInfo info) throws Exception {
                 ClientContext session = sessions.get(info.getProducerId().getParentId());
                 if (session == null) {



Mime
View raw message