You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2009/05/14 11:57:25 UTC
svn commit: r774712 - in /activemq/trunk:
activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java
Author: gtully
Date: Thu May 14 09:57:24 2009
New Revision: 774712
URL: http://svn.apache.org/viewvc?rev=774712&view=rev
Log:
resolve alternative path to https://issues.apache.org/activemq/browse/AMQ-2241 via ra where connection is reused. state tracker was not notified when remove command is suppressed and simulated during transport outage
Added:
activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java (with props)
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=774712&r1=774711&r2=774712&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java Thu May 14 09:57:24 2009
@@ -397,6 +397,7 @@
}
if(command instanceof RemoveInfo) {
// Simulate response to RemoveInfo command
+ stateTracker.track(command);
Response response = new Response();
response.setCorrelationId(command.getCommandId());
myTransportListener.onCommand(response);
Added: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java?rev=774712&view=auto
==============================================================================
--- activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java (added)
+++ activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java Thu May 14 09:57:24 2009
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.ra;
+
+import java.util.HashSet;
+
+import javax.resource.spi.ManagedConnection;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+
+
+public class FailoverManagedConnectionTest extends TestCase {
+
+ private static final String BROKER_TRANSPORT = "tcp://localhost:61616";
+ private static final String BROKER_URL = "failover://" + BROKER_TRANSPORT;
+
+ private ActiveMQManagedConnectionFactory managedConnectionFactory;
+ private ManagedConnection managedConnection;
+ private ManagedConnectionProxy proxy;
+ private BrokerService broker;
+ private HashSet<ManagedConnection> connections;
+ private ActiveMQConnectionRequestInfo connectionInfo;
+
+ protected void setUp() throws Exception {
+
+ createAndStartBroker();
+
+ connectionInfo = new ActiveMQConnectionRequestInfo();
+ connectionInfo.setServerUrl(BROKER_URL);
+ connectionInfo.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
+ connectionInfo.setPassword(ActiveMQConnectionFactory.DEFAULT_PASSWORD);
+
+ managedConnectionFactory = new ActiveMQManagedConnectionFactory();
+ managedConnection = managedConnectionFactory.createManagedConnection(null, connectionInfo);
+
+ connections = new HashSet<ManagedConnection>();
+ connections.add(managedConnection);
+ }
+
+
+ private void createAndStartBroker() throws Exception {
+ broker = new BrokerService();
+ broker.addConnector(BROKER_TRANSPORT);
+ broker.start();
+ broker.waitUntilStarted();
+ }
+
+ public void testFailoverBeforeClose() throws Exception {
+
+ createConnectionAndProxyAndSession();
+
+ stopBroker();
+
+ cleanupConnectionAndProxyAndSession();
+
+ createAndStartBroker();
+
+ for (int i=0; i<2; i++) {
+ createConnectionAndProxyAndSession();
+ cleanupConnectionAndProxyAndSession();
+ }
+ }
+
+
+ private void cleanupConnectionAndProxyAndSession() throws Exception {
+ proxy.close();
+ managedConnection.cleanup();
+ }
+
+
+ private void createConnectionAndProxyAndSession() throws Exception {
+ managedConnection =
+ managedConnectionFactory.matchManagedConnections(connections, null, connectionInfo);
+ proxy =
+ (ManagedConnectionProxy) managedConnection.getConnection(null, null);
+ proxy.createSession(false, 0);
+ }
+
+
+ private void stopBroker() throws Exception {
+ broker.stop();
+ broker.waitUntilStopped();
+ }
+
+}
Propchange: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/FailoverManagedConnectionTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date