gtully commented on a change in pull request #3863: URL: https://github.com/apache/activemq-artemis/pull/3863#discussion_r761911445
########## File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/balancing/ElasticQueueTest.java ########## @@ -0,0 +1,697 @@ +/* + * 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.artemis.tests.integration.balancing; + +import javax.jms.BytesMessage; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.ResourceAllocationException; +import javax.jms.Session; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.security.auth.Subject; +import java.io.File; +import java.net.URI; +import java.util.Set; +import java.util.Stack; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.management.AddressControl; +import org.apache.activemq.artemis.api.core.management.BrokerBalancerControl; +import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.balancing.BrokerBalancerConfiguration; +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; +import org.apache.activemq.artemis.core.security.CheckType; +import org.apache.activemq.artemis.core.security.Role; +import org.apache.activemq.artemis.core.server.balancing.targets.TargetKey; +import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; +import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; +import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy; +import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; +import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager5; +import org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal; +import org.apache.activemq.artemis.spi.core.security.jaas.UserPrincipal; +import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.Wait; +import org.apache.qpid.jms.JmsConnection; +import org.apache.qpid.jms.JmsConnectionFactory; +import org.apache.qpid.jms.JmsConnectionListener; +import org.apache.qpid.jms.message.JmsInboundMessageDispatch; +import org.junit.Assert; +import org.junit.Test; + +public class ElasticQueueTest extends ActiveMQTestBase { + + static final String qName = "EQ"; + static final SimpleString qNameSimple = SimpleString.toSimpleString(qName); + + final int base_port = 61616; + final int opTimeoutMillis = 2000; + final Stack<EmbeddedActiveMQ> nodes = new Stack<>(); + private final String balancerConfigName = "role_name_sharder"; + + String urlForNodes(Stack<EmbeddedActiveMQ> nodes) { + StringBuilder builder = new StringBuilder("failover:("); + int port_start = base_port; + for (EmbeddedActiveMQ activeMQ : nodes) { + if (port_start != base_port) { + builder.append(","); + } + builder.append("amqp://localhost:" + (port_start++)); + } + // fast reconnect, randomize to get to all brokers and timeout sends that block on no credit + builder.append(")?failover.maxReconnectDelay=2000&failover.randomize=true&jms.sendTimeout=" + opTimeoutMillis); + return builder.toString(); + } + + // allow tracking of failover reconnects + class ConnectionListener implements JmsConnectionListener { + + AtomicInteger connectionCount; + + ConnectionListener(AtomicInteger connectionCount) { + this.connectionCount = connectionCount; + } + + @Override + public void onConnectionEstablished(URI uri) { + } + + @Override + public void onConnectionFailure(Throwable throwable) { + } + + @Override + public void onConnectionInterrupted(URI uri) { + } + + @Override + public void onConnectionRestored(URI uri) { + connectionCount.incrementAndGet(); + } + + @Override + public void onInboundMessage(JmsInboundMessageDispatch jmsInboundMessageDispatch) { + } + + @Override + public void onSessionClosed(Session session, Throwable throwable) { + } + + @Override + public void onConsumerClosed(MessageConsumer messageConsumer, Throwable throwable) { + } + + @Override + public void onProducerClosed(MessageProducer messageProducer, Throwable throwable) { + } + } + + // slow consumer + class EQConsumer extends Thread { Review comment: agree. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
