[ 
https://issues.apache.org/jira/browse/ARTEMIS-4326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17736414#comment-17736414
 ] 

Davide Rosso commented on ARTEMIS-4326:
---------------------------------------

Hi Clebert, I'll try to explain better the test scenario.
There are two source codes attached:
h2. Publisher_UC4

A java class that implements an Artemis Publisher: the publisher sends 2 kinds 
of messages to the "uc4" address:
 # One, and only one, message with keyid = "DUMMY" and id = 0 (where keyid is 
the Last Value Key)
{code:java}
message.putStringProperty("keyid", "DUMMY");
message.putIntProperty("id", 0);
producer.send(message);
{code}

 # N messages in loop, with keyid = "KEY" and id = 1 to N
{code:java}
        for( int i=1; i <= messages; i ++) {
                message.putStringProperty("keyid", "KEY");
                message.putIntProperty("id", i);
            producer.send(message);
        }
{code}

Given the configuration of the address, I expect (but correct me if i'm wrong) 
that a consumer connecting to the LVQ queue receives:
 # The record (one) with keyid = "DUMMY" and id = 0
 # The last record published with keyid = "KEY" and id = <last id published>
 # The following records with keyid ="KEY" and id = <last id published> + X

h2. Subscriber_UC4_Core

A java class that implements an Artemis Consumer: the consumer accepts in input 
the name of the queue.
In this test case the consumer connects to the LVQ queue.
{code:java}
        public void onMessage(ClientMessage msg)   {
                        try {
                                String body = msg.getStringBody();

                                int id = msg.getIntProperty("id");
                                                String key = 
msg.getStringProperty("keyid");

                                                if (setOfIds.contains(id)) {
                                                        
System.err.println("****************** DUPLICATE ID :" + id + " key: " + key);
                                                } else {
                                                        
System.out.println("Received msg: " + "id = " + id + " key = " + key + " body = 
" + body);
                                                        setOfIds.add(id);
                                                }
........
                            try {
                                                        Thread.sleep(10);
                                                } catch (InterruptedException 
e) {
                                                        // TODO Auto-generated 
catch block
                                                        e.printStackTrace();
                                                }
{code}
The onMessage() method keeps track of all the id's received from the queue and 
signals when a duplicate key is received; a sleep of 10 millisec. then is added 
to the method in order to simulate a slow consumer.
In theory, I would not expect to receive duplicates, neither for records with 
keyid = "KEY", nor for the (only) record with keyid = "DUMMY".
What happens, instead, is that duplicates are received for both keyid's 

> Redelivery of messages in case of LVQ queue
> -------------------------------------------
>
>                 Key: ARTEMIS-4326
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4326
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.29.0
>            Reporter: Davide Rosso
>            Priority: Critical
>         Attachments: Publisher_UC4.java, Subscriber_UC4_Core.java
>
>
> An address configured as follows:
> {code:java}
>          <address name="uc4">
>             <multicast>
>                <queue name="uc4lvq" last-value-key="keyid" 
> non-destructive="true"/>
>             </multicast>
>             <anycast>
>                 <queue name="uc4queue" />
>             </anycast>
>          </address>{code}
> One producer, one consumer (the use case actually was built to test with 2 
> consumers, one reading from the LVQ queue, the other from the non-LVQ queue, 
> but the issue doesn't depend on the presence of the 2nd consumer).
>  * The producer sends 2 types of messages to the address "uc4"
>  ** 1 message with keyid = "DUMMY" and ID = 0 
>  ** N messages with keyid = "KEY" and ID = 1 to 20.000
>  * The consumer reads from the LVQ queue (uc4lvq); after each message, the 
> consumer sleeps for 10 millisecs. to simulate a "Slow" consumer. The consumer 
> keeps track of duplicate messages and writes the duplicate IDs.
>  * The producer starts and begins sending messages to the address. 
>  * When the producer has sent 2000 messages, the consumer is started.
> I would expect the consumer to
>  * Receive (once) the message with keyid = "DUMMY"
>  * Receive the last message with keyid = "KEY"
>  * Begin receiving the following messages.
> What happens instead is that some messages are redelivered twice; even the 
> message with KEY = "DUMMY", which is the 1st message ever sent to the broker, 
> is redelivered among the other more recent messages
>  
> {code:java}
> Received msg: id = 0 key = DUMMY body = null
> Received msg: id = 3322 key = KEY body = null
> Received msg: id = 3324 key = KEY body = null
> Received msg: id = 3327 key = KEY body = null
> Received msg: id = 3328 key = KEY body = null
> Received msg: id = 3333 key = KEY body = null
> Received msg: id = 3336 key = KEY body = null
> Received msg: id = 3338 key = KEY body = null
> Received msg: id = 3340 key = KEY body = null
> Received msg: id = 3342 key = KEY body = null
> Received msg: id = 3345 key = KEY body = null
> Received msg: id = 3346 key = KEY body = null
> Received msg: id = 3351 key = KEY body = null
> Received msg: id = 3355 key = KEY body = null
> Received msg: id = 3359 key = KEY body = null
> Received msg: id = 3361 key = KEY body = null
> Received msg: id = 3365 key = KEY body = null
> Received msg: id = 3367 key = KEY body = null
> Received msg: id = 3369 key = KEY body = null
> Received msg: id = 3371 key = KEY body = null
> Received msg: id = 3374 key = KEY body = null
> Received msg: id = 3376 key = KEY body = null
> Received msg: id = 3377 key = KEY body = null
> Received msg: id = 3379 key = KEY body = null
> Received msg: id = 3383 key = KEY body = null
> Received msg: id = 3386 key = KEY body = null
> Received msg: id = 3387 key = KEY body = null
> Received msg: id = 3389 key = KEY body = null
> Received msg: id = 3391 key = KEY body = null
> Received msg: id = 3394 key = KEY body = null
> Received msg: id = 3397 key = KEY body = null
> Received msg: id = 3401 key = KEY body = null
> Received msg: id = 3402 key = KEY body = null
> Received msg: id = 3404 key = KEY body = null
> Received msg: id = 3406 key = KEY body = null
> ****************** DUPLICATE ID :3406 key: KEY
> Received msg: id = 3407 key = KEY body = null
> Received msg: id = 3408 key = KEY body = null
> Received msg: id = 3410 key = KEY body = null
> Received msg: id = 3412 key = KEY body = null
> Received msg: id = 3413 key = KEY body = null
> Received msg: id = 3414 key = KEY body = null
> Received msg: id = 3415 key = KEY body = null
> Received msg: id = 3416 key = KEY body = null
> ****************** DUPLICATE ID :3416 key: KEY
> Received msg: id = 3417 key = KEY body = null
> Received msg: id = 3419 key = KEY body = null
> Received msg: id = 3420 key = KEY body = null
> Received msg: id = 3421 key = KEY body = null
> Received msg: id = 3422 key = KEY body = null
> Received msg: id = 3423 key = KEY body = null
> Received msg: id = 3425 key = KEY body = null
> ****************** DUPLICATE ID :3425 key: KEY
> Received msg: id = 3426 key = KEY body = null
> Received msg: id = 3430 key = KEY body = null
> Received msg: id = 3431 key = KEY body = null
> Received msg: id = 3432 key = KEY body = null
> Received msg: id = 3434 key = KEY body = null
> Received msg: id = 3435 key = KEY body = null
> Received msg: id = 3437 key = KEY body = null
> Received msg: id = 3439 key = KEY body = null
> ****************** DUPLICATE ID :0 key: DUMMY
> Received msg: id = 3444 key = KEY body = null
> Received msg: id = 3446 key = KEY body = null
> Received msg: id = 3449 key = KEY body = null
> Received msg: id = 3452 key = KEY body = null
> Received msg: id = 3455 key = KEY body = null
> Received msg: id = 3456 key = KEY body = null
> Received msg: id = 3458 key = KEY body = null
> Received msg: id = 3460 key = KEY body = null
> Received msg: id = 3462 key = KEY body = null
> Received msg: id = 3463 key = KEY body = null
> Received msg: id = 3466 key = KEY body = null
> Received msg: id = 3469 key = KEY body = null
> Received msg: id = 3470 key = KEY body = null
> Received msg: id = 3472 key = KEY body = null
> Received msg: id = 3473 key = KEY body = null
> Received msg: id = 3474 key = KEY body = null
> ****************** DUPLICATE ID :3474 key: KEY
> Received msg: id = 3475 key = KEY body = null
> Received msg: id = 3476 key = KEY body = null
> Received msg: id = 3478 key = KEY body = null
> Received msg: id = 3480 key = KEY body = null
> ...
> {code}
>  
> I attach the two source files used for this test case.
> I tried to write the Subscriber both with JMS and with the Core API, but the 
> result is the same.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to