[GitHub] activemq-artemis pull request #2473: ARTEMIS-1058 Jars in web tmp dir locked...

2018-12-19 Thread gaohoward
Github user gaohoward commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2473#discussion_r243139995
  
--- Diff: 
artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
 ---
@@ -237,28 +236,39 @@ public void start() throws Exception {
public void internalStop() throws Exception {
   server.stop();
   if (webContexts != null) {
+
  File tmpdir = null;
+ StringBuilder strBuilder = new StringBuilder();
+ boolean found = false;
  for (WebAppContext context : webContexts) {
 tmpdir = context.getTempDirectory();
 
-if (tmpdir != null && !context.isPersistTempDirectory()) {
+if (tmpdir != null && tmpdir.exists() && 
!context.isPersistTempDirectory()) {
//tmpdir will be removed by deleteOnExit()
-   //somehow when broker is stopped and restarted quickly
-   //this tmpdir won't get deleted sometimes
-   boolean fileDeleted = TimeUtils.waitOnBoolean(false, 5000, 
tmpdir::exists);
-
-   if (!fileDeleted) {
-  //because the execution order of shutdown hooks are
-  //not determined, so it's possible that the deleteOnExit
-  //is executed after this hook, in that case we force a 
delete.
-  FileUtil.deleteDirectory(tmpdir);
-  logger.debug("Force to delete temporary file on 
shutdown: " + tmpdir.getAbsolutePath());
-  if (tmpdir.exists()) {
- ActiveMQWebLogger.LOGGER.tmpFileNotDeleted(tmpdir);
-  }
+   //However because the URLClassLoader never release/close 
its opened
+   //jars the jar file won't be able to get deleted on Windows 
platform
+   //until after the process fully terminated. To fix this 
here arranges
+   //a separate process to try clean up the temp dir
+   FileUtil.deleteDirectory(tmpdir);
+   if (tmpdir.exists()) {
+  ActiveMQWebLogger.LOGGER.tmpFileNotDeleted(tmpdir);
+  strBuilder.append(tmpdir);
+  strBuilder.append(",");
+  found = true;
}
 }
  }
+
+ if (found) {
+String artemisHome = System.getProperty("artemis.home");
--- End diff --

This "artemis.home" property is not defined in configured in broker.xml 
file. It's only defined in artemis.profile and set to system property in 
artemis.cmd script (-Dartemis.home="$ARTEMIS_HOME")
I can't get it from the other configurations.



---


[GitHub] activemq-artemis issue #2467: ARTEMIS-2205 Performance improvements on AMQP ...

2018-12-19 Thread clebertsuconic
Github user clebertsuconic commented on the issue:

https://github.com/apache/activemq-artemis/pull/2467
  
@franz1981 I have pulled your netty change here for correctness. (Now with 
everything async I had an issue and I almost came up with a similar fix..yours 
was better and ready) :) 


---


[GitHub] activemq-artemis pull request #2473: ARTEMIS-1058 Jars in web tmp dir locked...

2018-12-19 Thread clebertsuconic
Github user clebertsuconic commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2473#discussion_r243083234
  
--- Diff: 
artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
 ---
@@ -237,28 +236,39 @@ public void start() throws Exception {
public void internalStop() throws Exception {
   server.stop();
   if (webContexts != null) {
+
  File tmpdir = null;
+ StringBuilder strBuilder = new StringBuilder();
+ boolean found = false;
  for (WebAppContext context : webContexts) {
 tmpdir = context.getTempDirectory();
 
-if (tmpdir != null && !context.isPersistTempDirectory()) {
+if (tmpdir != null && tmpdir.exists() && 
!context.isPersistTempDirectory()) {
//tmpdir will be removed by deleteOnExit()
-   //somehow when broker is stopped and restarted quickly
-   //this tmpdir won't get deleted sometimes
-   boolean fileDeleted = TimeUtils.waitOnBoolean(false, 5000, 
tmpdir::exists);
-
-   if (!fileDeleted) {
-  //because the execution order of shutdown hooks are
-  //not determined, so it's possible that the deleteOnExit
-  //is executed after this hook, in that case we force a 
delete.
-  FileUtil.deleteDirectory(tmpdir);
-  logger.debug("Force to delete temporary file on 
shutdown: " + tmpdir.getAbsolutePath());
-  if (tmpdir.exists()) {
- ActiveMQWebLogger.LOGGER.tmpFileNotDeleted(tmpdir);
-  }
+   //However because the URLClassLoader never release/close 
its opened
+   //jars the jar file won't be able to get deleted on Windows 
platform
+   //until after the process fully terminated. To fix this 
here arranges
+   //a separate process to try clean up the temp dir
+   FileUtil.deleteDirectory(tmpdir);
+   if (tmpdir.exists()) {
+  ActiveMQWebLogger.LOGGER.tmpFileNotDeleted(tmpdir);
+  strBuilder.append(tmpdir);
+  strBuilder.append(",");
+  found = true;
}
 }
  }
+
+ if (found) {
+String artemisHome = System.getProperty("artemis.home");
--- End diff --

can't you get the property from other means? Fileconfiguration for instance?


---


[GitHub] activemq-artemis issue #2470: Fixes for alerts from lgtm.com

2018-12-19 Thread clebertsuconic
Github user clebertsuconic commented on the issue:

https://github.com/apache/activemq-artemis/pull/2470
  
all lgtm, pun intended

If we could run the full testsuite just to be sure.


---


[GitHub] activemq-artemis pull request #2470: Fixes for alerts from lgtm.com

2018-12-19 Thread jbertram
Github user jbertram commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2470#discussion_r243076837
  
--- Diff: 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java
 ---
@@ -216,63 +216,63 @@ private static void printPages(DescribeJournal 
describeJournal,
 
  if (pgStore != null) {
 folder = pgStore.getFolder();
--- End diff --

The not-null check here on `pgStore` indicates that `pgStore` may, in fact, 
be null. If it is null then it will trigger a `NullPointerException` almost 
straight away.


---


[GitHub] activemq-artemis pull request #2470: Fixes for alerts from lgtm.com

2018-12-19 Thread clebertsuconic
Github user clebertsuconic commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2470#discussion_r243073035
  
--- Diff: 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java
 ---
@@ -216,63 +216,63 @@ private static void printPages(DescribeJournal 
describeJournal,
 
  if (pgStore != null) {
 folder = pgStore.getFolder();
--- End diff --

There's a semantic change here, are you sure?


---


[GitHub] activemq-artemis pull request #2464: ARTEMIS-1859 Incorrect routing with AMQ...

2018-12-19 Thread jbertram
Github user jbertram commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2464#discussion_r243026861
  
--- Diff: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
 ---
@@ -216,9 +219,23 @@ public RemotingConnection getRemotingConnection() {
   flow();
}
 
-   public RoutingType getRoutingType(Receiver receiver, SimpleString 
address) {
+   public RoutingType getRoutingType(Receiver receiver, SimpleString 
address, AMQPMessage message) {
   org.apache.qpid.proton.amqp.messaging.Target target = 
(org.apache.qpid.proton.amqp.messaging.Target) receiver.getRemoteTarget();
-  return target != null ? getRoutingType(target.getCapabilities(), 
address) : getRoutingType((Symbol[]) null, address);
+  // the target may be null or have no capabilities in the case of an 
anonymous producer
+  if (target != null && target.getCapabilities() != null) {
--- End diff --

I'll rework this. Thanks for the feedback, @gemmellr.


---


[GitHub] activemq-artemis pull request #2464: ARTEMIS-1859 Incorrect routing with AMQ...

2018-12-19 Thread jbertram
Github user jbertram closed the pull request at:

https://github.com/apache/activemq-artemis/pull/2464


---


[GitHub] activemq-artemis pull request #2468: Add CR in sanity check

2018-12-19 Thread BiNZGi
Github user BiNZGi closed the pull request at:

https://github.com/apache/activemq-artemis/pull/2468


---


[GitHub] activemq-artemis issue #2468: Add CR in sanity check

2018-12-19 Thread BiNZGi
Github user BiNZGi commented on the issue:

https://github.com/apache/activemq-artemis/pull/2468
  
Thank you for the hint with JIRA. Today I have made some more tests and 
recognized that there was a mismatch with the STOMP versions in my case. The 
messages were in STOMP 1.1 but with CR that is not allowed in this version.
Therefore I close this PR.


---


[GitHub] activemq-artemis issue #2468: Add CR in sanity check

2018-12-19 Thread jbertram
Github user jbertram commented on the issue:

https://github.com/apache/activemq-artemis/pull/2468
  
After looking at this a bit more closely I think this change is incorrect. 
The optional carriage return (octet 13) was added in STOMP 1.2, but you have 
changed `org.apache.activemq.artemis.core.protocol.stomp.StompDecoder` which is 
responsible for STOMP 1.0 frames. There are different decoder implementations 
for STOMP 1.1 & 1.2, and from what I can tell the 1.2 decoder handles the EOL 
properly. In fact, the STOMP client used by the test suite sends `\r\n` EOLs by 
default when using STOMP 1.2. 

Unless you have a test demonstrating a problem I think this PR should be 
closed.


---


[GitHub] activemq-artemis issue #2473: ARTEMIS-1058 Jars in web tmp dir locked on Win...

2018-12-19 Thread gaohoward
Github user gaohoward commented on the issue:

https://github.com/apache/activemq-artemis/pull/2473
  
Yes there is a issue opened. 
https://github.com/eclipse/jetty.project/issues/1425
that doesn't get fixed (PR didn't merged because the hacking into 
URLClassLoader brings concerns)
So that's why i came up with this work around.
(The issue still there with jetty latest releases).


---


[GitHub] activemq-artemis pull request #2467: ARTEMIS-2205 Performance improvements o...

2018-12-19 Thread franz1981
Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2467#discussion_r242970329
  
--- Diff: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ExecutorNettyAdapter.java
 ---
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat 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.protocol.amqp.proton.handler;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelPromise;
+import io.netty.channel.EventLoop;
+import io.netty.channel.EventLoopGroup;
+import io.netty.util.concurrent.EventExecutor;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.ProgressivePromise;
+import io.netty.util.concurrent.Promise;
+import io.netty.util.concurrent.ScheduledFuture;
+import org.apache.activemq.artemis.utils.actors.ArtemisExecutor;
+
+/** Test cases may supply a simple executor instead of the real Netty 
Executor
+ *  On that case this is a simple adapter for what's needed from these 
tests.
+ *  Not intended to be used in production.
+ *
+ *  TODO: This could be refactored out of the main codebase but at a high 
cost.
+ *We may do it some day if we find an easy way that won't clutter 
the code too much.
+ *  */
+public class ExecutorNettyAdapter implements EventLoop {
--- End diff --

If you would add a comment on the path where is being used it would help 
(me that I have a bad memory) to remember it mate!


---


[GitHub] activemq-artemis issue #2473: ARTEMIS-1058 Jars in web tmp dir locked on Win...

2018-12-19 Thread jbertram
Github user jbertram commented on the issue:

https://github.com/apache/activemq-artemis/pull/2473
  
Wasn't there a Jetty issue opened about this? If so, how was that resolved?


---


[GitHub] activemq-artemis pull request #2467: ARTEMIS-2205 Performance improvements o...

2018-12-19 Thread clebertsuconic
Github user clebertsuconic commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2467#discussion_r242969136
  
--- Diff: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ExecutorNettyAdapter.java
 ---
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat 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.protocol.amqp.proton.handler;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelPromise;
+import io.netty.channel.EventLoop;
+import io.netty.channel.EventLoopGroup;
+import io.netty.util.concurrent.EventExecutor;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.ProgressivePromise;
+import io.netty.util.concurrent.Promise;
+import io.netty.util.concurrent.ScheduledFuture;
+import org.apache.activemq.artemis.utils.actors.ArtemisExecutor;
+
+/** Test cases may supply a simple executor instead of the real Netty 
Executor
+ *  On that case this is a simple adapter for what's needed from these 
tests.
+ *  Not intended to be used in production.
+ *
+ *  TODO: This could be refactored out of the main codebase but at a high 
cost.
+ *We may do it some day if we find an easy way that won't clutter 
the code too much.
+ *  */
+public class ExecutorNettyAdapter implements EventLoop {
--- End diff --

@franz1981 that's correct.

Placing it on the testsuite only would require some work that I do not want 
to go through.


---


[GitHub] activemq-artemis pull request #2467: ARTEMIS-2205 Performance improvements o...

2018-12-19 Thread clebertsuconic
Github user clebertsuconic commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2467#discussion_r242968808
  
--- Diff: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
 ---
@@ -730,22 +793,29 @@ public int deliverMessage(MessageReference 
messageReference, int deliveryCount,
 
 if (preSettle) {
// Presettled means the client implicitly accepts any 
delivery we send it.
-   sessionSPI.ack(null, brokerConsumer, 
messageReference.getMessage());
+   try {
+  sessionSPI.ack(null, brokerConsumer, 
messageReference.getMessage());
+   } catch (Exception e) {
+  log.debug(e.getMessage(), e);
+   }
delivery.settle();
 } else {
sender.advance();
 }
 
 connection.flush();
  } finally {
-connection.unlock();
+synchronized (creditsLock) {
+   pending.decrementAndGet();
+}
+if (releaseRequired) {
+   ((NettyReadable) sendBuffer).getByteBuf().release();
+}
  }
+  } catch (Exception e) {
+ log.warn(e.getMessage(), e);
 
- return size;
-  } finally {
- if (releaseRequired) {
-((NettyReadable) sendBuffer).getByteBuf().release();
- }
+ // important todo: Error treatment
--- End diff --

ouch... let me see


---


[GitHub] activemq-artemis issue #2473: ARTEMIS-1058 Jars in web tmp dir locked on Win...

2018-12-19 Thread gaohoward
Github user gaohoward commented on the issue:

https://github.com/apache/activemq-artemis/pull/2473
  
manually tested on Windows 7 64bit and Windows 10 64bit.


---


[GitHub] activemq-artemis pull request #2473: ARTEMIS-1058 Jars in web tmp dir locked...

2018-12-19 Thread gaohoward
GitHub user gaohoward opened a pull request:

https://github.com/apache/activemq-artemis/pull/2473

ARTEMIS-1058 Jars in web tmp dir locked on Windows

Because Sun's URLClassLoader never closes it's jar file handles
Jetty doesn't cleanup is temp web dir after Artemis broker shut
down normally on Windows.

To work around this a new process is forked before broker VM
exits to clean up the tmp dir if they are not deleted. The
new process out lives the main VM so that those jar's handles
are released and the temp dir can be cleaned up.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/gaohoward/activemq-artemis b_522

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/activemq-artemis/pull/2473.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2473


commit af27cc96555390ec63d35e9c157aa658bde60797
Author: Howard Gao 
Date:   2018-12-19T14:54:59Z

ARTEMIS-1058 Jars in web tmp dir locked on Windows

Because Sun's URLClassLoader never closes it's jar file handles
Jetty doesn't cleanup is temp web dir after Artemis broker shut
down normally on Windows.

To work around this a new process is forked before broker VM
exits to clean up the tmp dir if they are not deleted. The
new process out lives the main VM so that those jar's handles
are released and the temp dir can be cleaned up.




---


[GitHub] activemq-artemis pull request #2472: ARTEMIS-2208 Fix Unit Tests Pom

2018-12-19 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/activemq-artemis/pull/2472


---


[GitHub] activemq-artemis pull request #2467: ARTEMIS-2205 Performance improvements o...

2018-12-19 Thread franz1981
Github user franz1981 commented on a diff in the pull request:

https://github.com/apache/activemq-artemis/pull/2467#discussion_r242903263
  
--- Diff: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ExecutorNettyAdapter.java
 ---
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2005-2014 Red Hat, Inc.
+ * Red Hat 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.protocol.amqp.proton.handler;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelPromise;
+import io.netty.channel.EventLoop;
+import io.netty.channel.EventLoopGroup;
+import io.netty.util.concurrent.EventExecutor;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.ProgressivePromise;
+import io.netty.util.concurrent.Promise;
+import io.netty.util.concurrent.ScheduledFuture;
+import org.apache.activemq.artemis.utils.actors.ArtemisExecutor;
+
+/** Test cases may supply a simple executor instead of the real Netty 
Executor
+ *  On that case this is a simple adapter for what's needed from these 
tests.
+ *  Not intended to be used in production.
+ *
+ *  TODO: This could be refactored out of the main codebase but at a high 
cost.
+ *We may do it some day if we find an easy way that won't clutter 
the code too much.
+ *  */
+public class ExecutorNettyAdapter implements EventLoop {
--- End diff --

I see that ExecutorNettyAdapter is used on AMQPConnectionContext: do you 
mean that only tests trigger ExecutorNettyAdapter to be created?


---


[GitHub] activemq-artemis pull request #2472: ARTEMIS-2208 Fix Unit Tests Pom

2018-12-19 Thread mtaylor
GitHub user mtaylor opened a pull request:

https://github.com/apache/activemq-artemis/pull/2472

ARTEMIS-2208 Fix Unit Tests Pom



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/mtaylor/activemq-artemis ARTEMIS-2208

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/activemq-artemis/pull/2472.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2472


commit 4445e7ce181a926332ba0ced43092e651ae5ad71
Author: Martyn Taylor 
Date:   2018-12-19T09:51:27Z

ARTEMIS-2208 Fix Unit Tests Pom




---


[GitHub] activemq-artemis pull request #2466: ARTEMIS-2206 The MQTT consumer reconnec...

2018-12-19 Thread onlyMIT
GitHub user onlyMIT reopened a pull request:

https://github.com/apache/activemq-artemis/pull/2466

ARTEMIS-2206 The MQTT consumer reconnection caused the queue to not be 
cle…

### Test environment

1. Use 10,000 (9 thousand senders, 1 thousand consumers) MQTT connection on 
one server to test Artemis, set the 'cleanSession' property to true;
2. MQTT client: paho 1.2.0;
3. Server: CPU Cores:32, Mem:64G, SSD:250G, HDD:1T

### Issue

**Issue 1**
Artemis broker has the following exception log:
`[Thread-0 
(ActiveMQ-remoting-threads-ActiveMQServerImpl::serverUUID=fb358579-feb3-11e8-bc7c-141877a7fd13-1409545055)]
 17:27:59,035 WARN  [org.apache.activemq.artemis.utils.actors.OrderedExecutor] 
null: java.lang.NullPointerException
at 
org.apache.activemq.artemis.core.protocol.mqtt.MQTTProtocolManager.isClientConnected(MQTTProtocolManager.java:182)
 [:]
at 
org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnectionManager.disconnect(MQTTConnectionManager.java:150)
 [:]
at 
org.apache.activemq.artemis.core.protocol.mqtt.MQTTFailureListener.connectionFailed(MQTTFailureListener.java:37)
 [:]
at 
org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnection.fail(MQTTConnection.java:147)
 [:]
at 
org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.issueFailure(RemotingServiceImpl.java:561)
 [:]
at 
org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl.connectionDestroyed(RemotingServiceImpl.java:542)
 [:]
at 
org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor$Listener.connectionDestroyed(NettyAcceptor.java:858)
 [:]
at 
org.apache.activemq.artemis.core.remoting.impl.netty.ActiveMQChannelHandler.lambda$channelInactive$0(ActiveMQChannelHandler.java:83)
 [:]
at 
org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:42)
 [:]
at 
org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:31)
 [:]
at 
org.apache.activemq.artemis.utils.actors.ProcessorBase.executePendingTasks(ProcessorBase.java:66)
 [:]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
[rt.jar:1.8.0_101]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
[rt.jar:1.8.0_101]
at 
org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
 [:]`

**Issue 2**
After closing all client connections, 64 queues were not cleaned up。

### Analysis and simulation reproduction

  When the MQTT consumer client (cleanSession property set to true) 
reconnected,There is a certain probability that the queue will not be 
automatically cleared and a NullPointerException will be thrown.
  This is because the MQTT consumer client thinks that its connection has 
been disconnected and triggers reconnection, but the MQTT connection is still 
alive at Artemis broker. This bug occurs when the Artemis broker to start 
processing a ‘new MQTT connection’ while closing the ‘old MQTT 
connection’.
  Create an MQTT consumer (cleanSession: true, clientID: superConsumer, 
topic: mit.test) and connect to the Artemis broker. Create another MQTT 
consumer to set the same cleanSession, clientID, and topic, then start 
connecting with the Artemis broker. Close the two MQTT connections, and so many 
times after repeated trials, there is a probability to reproduce the two 
problems mentioned above.

### Solution

**Issue 1**

  When 'session.getProtocolManager().isClientConnected(clientId, 
session.getConnection())' is called, if the 'MQTTConnection' instance retrieved 
from 'connectedClients' is 'null', a NullPointerException is thrown. Add a 
non-null decision in the 'MQTTProtocolManager.isClientConnected' method.

**Issue 2** 

1. Remove ‘InterruptedException’ from the 
‘MQTTConnectionManager.getSessionState’ method because the 
‘InterruptedException’ exception will never be thrown in this method;
2. 'MQTTConnectionManager.connect' and 'MQTTConnectionManager.disconnect' 
methods add 'synchronized' with the MQTTSessionState instance as a lock.In the 
Artemis broker, all MQTT connections using the same clientId share the same 
MQTTSessionState instance. After adding this lock, you can avoid calling the 
'connect' and 'disconnect' methods on the MQTT connections with the same 
clientId.
3. For the MQTT protocol, there is one and only one consumer connection per 
queue, which is a good choice for closing the old MQTT consumer before the new 
MQTT consumer connects.
The original code could not effectively clean up the 'old consumer' in 
the queue when the 'new MQTT connection' was connected to the Artemis broker. 
Modify ‘MQTTSubscriptionManager.removeSubscription’ to get the queue 
consumer collection from 

[GitHub] activemq-artemis issue #2466: ARTEMIS-2206 The MQTT consumer reconnection ca...

2018-12-19 Thread onlyMIT
Github user onlyMIT commented on the issue:

https://github.com/apache/activemq-artemis/pull/2466
  
@clebertsuconic  Sorry, the pull request has been closed due to my 
misoperation, and it has now been restored. thank you very much for your help


---


[GitHub] activemq-artemis pull request #2466: ARTEMIS-2206 The MQTT consumer reconnec...

2018-12-19 Thread onlyMIT
Github user onlyMIT closed the pull request at:

https://github.com/apache/activemq-artemis/pull/2466


---