You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2022/11/09 18:51:20 UTC
[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4283: ARTEMIS-4084 Fixing addSorted with large transactions
clebertsuconic commented on code in PR #4283:
URL: https://github.com/apache/activemq-artemis/pull/4283#discussion_r1018302422
##########
tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/client/ClientCrashMassiveRollbackTest.java:
##########
@@ -0,0 +1,121 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.soak.client;
+
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import org.apache.activemq.artemis.api.core.QueueConfiguration;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.client.ClientProducer;
+import org.apache.activemq.artemis.api.core.client.ClientSession;
+import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
+import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
+import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.management.QueueControl;
+import org.apache.activemq.artemis.api.core.management.ResourceNames;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.utils.critical.CriticalAnalyzerPolicy;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ClientCrashMassiveRollbackTest extends ActiveMQTestBase {
+ protected ActiveMQServer server;
+ protected ClientSession session;
+ protected ClientSessionFactory sf;
+ protected ServerLocator locator;
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ Configuration config = createDefaultNettyConfig();
+ config.setCriticalAnalyzer(true);
+ config.setCriticalAnalyzerTimeout(10000);
+ config.setCriticalAnalyzerCheckPeriod(5000);
+ config.setConnectionTTLOverride(5000);
+ config.setCriticalAnalyzerPolicy(CriticalAnalyzerPolicy.LOG);
+ server = createServer(false, config);
+ server.start();
+ }
+
+ @Test
+ public void clientCrashMassiveRollbackTest() throws Exception {
+ final String queueName = "queueName";
+ final int messageCount = 1000000;
+
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("(tcp://localhost:61616)");
+ factory.setConsumerWindowSize(-1);
+ factory.setConfirmationWindowSize(10240000);
+ Connection connection = factory.createConnection();
+ connection.start();
+
+ Thread thread = new Thread(() -> {
+ try {
+ Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Queue destination = consumerSession.createQueue(queueName);
+ MessageConsumer consumer = consumerSession.createConsumer(destination);
+ for (;;) {
+ consumer.receive();
+ }
+ } catch (Exception e) {
+ }
+ });
+
+ locator = createNettyNonHALocator();
+ locator.setConfirmationWindowSize(10240000);
+ sf = createSessionFactory(locator);
+ session = addClientSession(sf.createSession(false, true, true));
+ SendAcknowledgementHandler sendHandler = message -> {
+ };
+ session.setSendAcknowledgementHandler(sendHandler);
+ session.createQueue(new QueueConfiguration(queueName).setAddress(queueName).setRoutingType(RoutingType.ANYCAST));
+ ClientProducer producer = session.createProducer(queueName);
+ QueueControl queueControl = (QueueControl)server.getManagementService().getResource(ResourceNames.QUEUE + queueName);
+
+ thread.start();
+
+ for (int i = 0; i < messageCount; i++) {
+ producer.send(session.createMessage(true));
+ }
+ producer.close();
+
+ while (queueControl.getDeliveringCount() < messageCount) {
+ Thread.sleep(1000);
+ }
+
+ //Ran the consumer in a thread to be able to kill it "uncleanly"
+ //Thread.stop() is deprecated for the reason I am exploiting here
+ thread.stop();
+
+
+
+ Assert.assertEquals(messageCount, queueControl.getMessageCount());
+ Assert.assertEquals(ActiveMQServer.SERVER_STATE.STARTED, server.getState());
+
+ Thread.sleep(5000);
Review Comment:
this was a mistake... I didn't mean to keep it
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org