assens commented on a change in pull request #2837: ARTEMIS-2476: New MQTT 
subscriptions receive older (not last published) retained message.
URL: https://github.com/apache/activemq-artemis/pull/2837#discussion_r324993925
 
 

 ##########
 File path: 
artemis-protocols/artemis-mqtt-protocol/src/test/java/org/apache/activemq/artemis/core/protocol/mqtt/MqttClientService.java
 ##########
 @@ -0,0 +1,126 @@
+/*
+ * 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.core.protocol.mqtt;
+
+import static java.util.Objects.nonNull;
+import static 
org.eclipse.paho.client.mqttv3.MqttConnectOptions.MQTT_VERSION_3_1_1;
+
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.function.Consumer;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
+import org.eclipse.paho.client.mqttv3.MqttCallback;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.jboss.logging.Logger;
+
+import io.netty.util.concurrent.DefaultThreadFactory;
+
+public class MqttClientService implements MqttCallback {
 
 Review comment:
   Hi. The MQTTRetainMessageManagerTest uses [Eclipse 
Paho](https://www.eclipse.org/paho/) MQTT client to connect to Artemis. 
MqttCallback is an interface defined by the Paho client, that provides a call 
back when a message is received. 
   
   The MqttClientService used by the MQTTRetainMessageManagerTest uses the Paho 
MQTT client to publish messages and at the same time implements the 
MqttCallback to be able to subscribe and receive messages.
   
   The MQTTRetainMessageManagerTest uses 4 instances of MqttClientService. 
   
   - mqttConsumerCount is used only to count the messages received by it as 
consumer
   - mqttConsumerBeforePublish is a consumer which subscribes to the fact 
topic, before any publishing starts. 
   - arrivedCountAferPublish and arrivedCountAferPublish2 are consumers that 
subscribe after messages are published.
   
   See how the actAndAssert method uses the 4 clients. 
   
   The goal of the test is to assert that retained message received by all 
client subscriptions  (before and after the publish) is equal to the last 
retained message published.
   
   In addition, I've created a [mqtt-test](https://github.com/assens/mqtt-test) 
project that demonstrates the problem we have with Artemis, and also shows that 
other brokers such as Ejabberd, Emqx, HiveMQ, Moquette, Mosquitto, RabbitMQ and 
VerneMQ don't have such problem.
   
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to