From dev-return-68898-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Thu Jan 10 10:10:03 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 087F2180679 for ; Thu, 10 Jan 2019 10:10:02 +0100 (CET) Received: (qmail 23357 invoked by uid 500); 10 Jan 2019 09:09:51 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 23346 invoked by uid 99); 10 Jan 2019 09:09:50 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jan 2019 09:09:50 +0000 From: GitBox To: dev@activemq.apache.org Subject: =?utf-8?q?=5BGitHub=5D_onlyMIT_commented_on_a_change_in_pull_request_=232?= =?utf-8?q?466=3A_ARTEMIS-2206_The_MQTT_consumer_reconnection_caused_the_q?= =?utf-8?q?ueue_to_not_be_cle=E2=80=A6?= Message-ID: <154711130900.2628.13766637941462422024.gitbox@gitbox.apache.org> Date: Thu, 10 Jan 2019 09:08:29 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit onlyMIT commented on a change in pull request #2466: ARTEMIS-2206 The MQTT consumer reconnection caused the queue to not be cle… URL: https://github.com/apache/activemq-artemis/pull/2466#discussion_r246680631 ########## File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTQueueCleanTest.java ########## @@ -0,0 +1,109 @@ +/** + * 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.mqtt.imported; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.postoffice.Binding; +import org.apache.activemq.artemis.core.postoffice.PostOffice; +import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; +import org.apache.activemq.artemis.core.server.Queue; +import org.junit.Test; + +import java.util.HashSet; +import java.util.Random; +import java.util.Set; + +public class MQTTQueueCleanTest extends MQTTTestSupport { + + private static final ActiveMQServerLogger log = ActiveMQServerLogger.LOGGER; + + @Test + public void testQueueCleanWhenConnectionSynExeConnectAndDisconnect() throws Exception { + Random random = new Random(); + Set clientProviders = new HashSet<>(11); + int repeatCount = 0; + String address = "clean/test"; + String clientId = "sameClientId"; + String queueName = "::sameClientId.clean.test"; + //The abnormal scene does not necessarily occur, repeating 100 times to ensure the recurrence of the abnormality + while (repeatCount < 100) { + repeatCount++; + int subConnectionCount = random.nextInt(50) + 1; + int sC = 0; + try { + //Reconnect at least twice to reproduce the problem + while (sC < subConnectionCount) { + sC++; + MQTTClientProvider clientProvider = getMQTTClientProvider(); + clientProvider.setClientId(clientId); + initializeConnection(clientProvider); + clientProviders.add(clientProvider); + clientProvider.subscribe(address, AT_LEAST_ONCE); + } + } finally { + for (MQTTClientProvider clientProvider : clientProviders) { + clientProvider.disconnect(); + } + clientProviders.clear(); + assertTrue(waitForBindings(server, queueName, false, 0, 0, 10000)); Review comment: I pushed an update to addressyour suggestion. And removed `synchronized `from some methods ( `MQTTConnectionManager.connect`, `MQTTConnectionManager.disconnect`, `MQTTSubscriptionManager.removeSubscription` ). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services