mirror of https://github.com/apache/activemq.git
patch and test case for AMQ-514 to make BrokerInfo and the broker name visible to an ActiveMQConnection
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@373548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
92b9d864e5
commit
e6747ead95
|
@ -1214,6 +1214,23 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
||||||
return brokerInfo.getBrokerId().getValue();
|
return brokerInfo.getBrokerId().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the broker name if one is available or null if one is not available yet.
|
||||||
|
*/
|
||||||
|
public String getBrokerName() {
|
||||||
|
if (brokerInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return brokerInfo.getBrokerName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the broker information if it is available or null if it is not available yet.
|
||||||
|
*/
|
||||||
|
public BrokerInfo getBrokerInfo() {
|
||||||
|
return brokerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the RedeliveryPolicy.
|
* @return Returns the RedeliveryPolicy.
|
||||||
* @throws JMSException
|
* @throws JMSException
|
||||||
|
|
|
@ -60,6 +60,18 @@ public class ActiveMQConnectionFactoryTest extends CombinationTestSupport {
|
||||||
assertNull( BrokerRegistry.getInstance().lookup("localhost") );
|
assertNull( BrokerRegistry.getInstance().lookup("localhost") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetBrokerName() throws URISyntaxException, JMSException {
|
||||||
|
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
|
||||||
|
ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
|
||||||
|
connection.start();
|
||||||
|
|
||||||
|
String brokerName = connection.getBrokerName();
|
||||||
|
System.out.println("Got broker name: " + brokerName);
|
||||||
|
|
||||||
|
assertNotNull("No broker name available!", brokerName);
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
|
||||||
public void testCreateTcpConnectionUsingAllocatedPort() throws Exception {
|
public void testCreateTcpConnectionUsingAllocatedPort() throws Exception {
|
||||||
assertCreateConnection("tcp://localhost:0?wireFormat.tcpNoDelayEnabled=true");
|
assertCreateConnection("tcp://localhost:0?wireFormat.tcpNoDelayEnabled=true");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue