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

Albertas Vyšniauskas commented on AMQ-9395:
-------------------------------------------

Looks like the order of received messages depends on HashSet iteration order. 
Composite destination physical name is split into multiple strings and added to 
HashSet (see 
[https://github.com/apache/activemq/blob/65a6b805a04766ab0523033634c00cc338090217/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQDestination.java#L284)|https://github.com/apache/activemq/blob/65a6b805a04766ab0523033634c00cc338090217/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQDestination.java#L284).].

According to HashSet documentation, the order of the set iteration is 
undefined: "It makes no guarantees as to the iteration order of the set; in 
particular, it does not guarantee that the order will remain constant over 
time."

This means that the order in which messages are sent to destinations in 
composite destination is also undefined and may change at any time.

It would probably be nicer to keep the order of destinations the same as 
specified in composite destination physical name, so that sending a message to 
"a/1,a/2" would send to "a/1", and then to "a/2".

> Is the order of testMQTTCompositeDestinations guarenteed?
> ---------------------------------------------------------
>
>                 Key: AMQ-9395
>                 URL: https://issues.apache.org/jira/browse/AMQ-9395
>             Project: ActiveMQ Classic
>          Issue Type: Bug
>            Reporter: huiyang chi
>            Priority: Blocker
>
> For this method
> [https://github.com/apache/activemq/blob/dfd35d89f62558881bda1ed4cf7a165502c5c989/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java#L382]
>  
> This test used the Composite Topic Publishing, and assume the client will 
> receive the message from `a/2`, then receive message from the `a/1`, is there 
> any guarantee regarding this? 



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

Reply via email to