http://issues.apache.org/jira/browse/AMQ-3178 - 5.3.x clients to 5.4 brokers always get updated cluster information in the broker info, this should be configurable

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1069846 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-02-11 15:42:38 +00:00
parent cfdd68c799
commit bf4dd7330d
2 changed files with 43 additions and 1 deletions

View File

@ -887,7 +887,11 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
transport.start(); transport.start();
active = true; active = true;
BrokerInfo info = connector.getBrokerInfo().copy(); BrokerInfo info = connector.getBrokerInfo().copy();
if (connector.isUpdateClusterClients()) {
info.setPeerBrokerInfos(this.broker.getPeerBrokerInfos()); info.setPeerBrokerInfos(this.broker.getPeerBrokerInfos());
} else {
info.setPeerBrokerInfos(null);
}
dispatchAsync(info); dispatchAsync(info);
connector.onStarted(this); connector.onStarted(this);

View File

@ -16,7 +16,9 @@
*/ */
package org.apache.activemq.transport.failover; package org.apache.activemq.transport.failover;
import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.concurrent.TimeUnit;
import javax.jms.DeliveryMode; import javax.jms.DeliveryMode;
@ -26,6 +28,7 @@ import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.command.BrokerInfo;
import org.apache.activemq.command.ConnectionInfo; import org.apache.activemq.command.ConnectionInfo;
import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.ConsumerInfo;
import org.apache.activemq.command.ProducerInfo; import org.apache.activemq.command.ProducerInfo;
@ -33,6 +36,7 @@ import org.apache.activemq.command.SessionInfo;
import org.apache.activemq.network.NetworkTestSupport; import org.apache.activemq.network.NetworkTestSupport;
import org.apache.activemq.transport.Transport; import org.apache.activemq.transport.Transport;
import org.apache.activemq.transport.TransportFactory; import org.apache.activemq.transport.TransportFactory;
import org.apache.activemq.transport.TransportListener;
import org.apache.activemq.transport.multicast.MulticastTransportTest; import org.apache.activemq.transport.multicast.MulticastTransportTest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -113,6 +117,40 @@ public class FailoverTransportBrokerTest extends NetworkTestSupport {
} }
public void testNoBrokersInBrokerInfo() throws Exception {
final BrokerInfo info[] = new BrokerInfo[1];
StubConnection c = createFailoverConnection();
c.setListener(new TransportListener() {
@Override
public void onCommand(Object command) {
if (command instanceof BrokerInfo) {
info[0] = (BrokerInfo) command;
}
}
@Override
public void onException(IOException error) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void transportInterupted() {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void transportResumed() {
//To change body of implemented methods use File | Settings | File Templates.
}
});
c.start();
int count = 0;
while(count++ < 5 && info[0] == null) {
TimeUnit.SECONDS.sleep(1);
}
assertNull("no peer brokers present", info[0].getPeerBrokerInfos());
}
protected String getLocalURI() { protected String getLocalURI() {
return "tcp://localhost:0?wireFormat.tcpNoDelayEnabled=true"; return "tcp://localhost:0?wireFormat.tcpNoDelayEnabled=true";
} }