mirror of https://github.com/apache/activemq.git
Remove the dependency on the fixed 61616 port number
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1174734 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d314b7f57d
commit
2db7cbf436
|
@ -56,16 +56,17 @@ public class AMQ2021Test extends TestCase implements ExceptionListener, Uncaught
|
|||
|
||||
AMQ2021Test testCase;
|
||||
|
||||
String ACTIVEMQ_BROKER_BIND = "tcp://localhost:61616";
|
||||
String ACTIVEMQ_BROKER_URL = ACTIVEMQ_BROKER_BIND + "?jms.redeliveryPolicy.maximumRedeliveries=1&jms.redeliveryPolicy.initialRedeliveryDelay=0";
|
||||
private final String ACTIVEMQ_BROKER_BIND = "tcp://localhost:0";
|
||||
private String CONSUMER_BROKER_URL = "?jms.redeliveryPolicy.maximumRedeliveries=1&jms.redeliveryPolicy.initialRedeliveryDelay=0";
|
||||
private String PRODUCER_BROKER_URL;
|
||||
|
||||
private int numMessages = 1000;
|
||||
private int numConsumers = 2;
|
||||
private int dlqMessages = numMessages/2;
|
||||
private final int numMessages = 1000;
|
||||
private final int numConsumers = 2;
|
||||
private final int dlqMessages = numMessages/2;
|
||||
|
||||
CountDownLatch receivedLatch;
|
||||
private CountDownLatch receivedLatch;
|
||||
private ActiveMQTopic destination;
|
||||
public CountDownLatch started;
|
||||
private CountDownLatch started;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
@ -80,6 +81,9 @@ public class AMQ2021Test extends TestCase implements ExceptionListener, Uncaught
|
|||
destination = new ActiveMQTopic(getName());
|
||||
exceptions = new Vector<Throwable>();
|
||||
|
||||
CONSUMER_BROKER_URL = brokerService.getTransportConnectors().get(0).getPublishableConnectString() + CONSUMER_BROKER_URL;
|
||||
PRODUCER_BROKER_URL = brokerService.getTransportConnectors().get(0).getPublishableConnectString();
|
||||
|
||||
receivedLatch =
|
||||
new CountDownLatch(numConsumers * (numMessages + dlqMessages));
|
||||
started = new CountDownLatch(1);
|
||||
|
@ -116,7 +120,7 @@ public class AMQ2021Test extends TestCase implements ExceptionListener, Uncaught
|
|||
threads.add(producer);
|
||||
producer.start();
|
||||
|
||||
boolean allGood = receivedLatch.await(30, TimeUnit.SECONDS);
|
||||
boolean allGood = receivedLatch.await(90, TimeUnit.SECONDS);
|
||||
for (Throwable t: exceptions) {
|
||||
log.error("failing test with first exception", t);
|
||||
fail("exception during test : " + t);
|
||||
|
@ -139,7 +143,7 @@ public class AMQ2021Test extends TestCase implements ExceptionListener, Uncaught
|
|||
|
||||
private void consumeFromDLQ( int messageCount) throws Exception {
|
||||
ActiveMQConnectionFactory connectionFactory =
|
||||
new ActiveMQConnectionFactory(ACTIVEMQ_BROKER_URL);
|
||||
new ActiveMQConnectionFactory(CONSUMER_BROKER_URL);
|
||||
Connection connection = connectionFactory.createConnection();
|
||||
connection.start();
|
||||
|
||||
|
@ -158,7 +162,7 @@ public class AMQ2021Test extends TestCase implements ExceptionListener, Uncaught
|
|||
public void produce(int count) throws Exception {
|
||||
Connection connection=null;
|
||||
try {
|
||||
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(ACTIVEMQ_BROKER_BIND);
|
||||
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(PRODUCER_BROKER_URL);
|
||||
connection = factory.createConnection();
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
MessageProducer producer = session.createProducer(destination);
|
||||
|
@ -200,7 +204,7 @@ public class AMQ2021Test extends TestCase implements ExceptionListener, Uncaught
|
|||
public void run() {
|
||||
try {
|
||||
ActiveMQConnectionFactory connectionFactory =
|
||||
new ActiveMQConnectionFactory(ACTIVEMQ_BROKER_URL);
|
||||
new ActiveMQConnectionFactory(CONSUMER_BROKER_URL);
|
||||
Connection connection = connectionFactory.createConnection();
|
||||
connection.setExceptionListener(testCase);
|
||||
connection.setClientID(getName());
|
||||
|
|
Loading…
Reference in New Issue