Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
5.4.2
-
None
-
None
Description
When an ajax client is subscribed to multiple topics, the "id" attribute of a returned <response> element indicates to JavaScript which callback function should process the message. Currently, the MessageListenerServlet returns multiple copies of each message, 1 per subscription. So all callback functions will receive all messages.
For example, if I send messages 'A1' and 'A2' to /topic/topicA, and messages 'B1' and 'B2' to /topic/topicB, my ajax client gets the following message:
<ajax-response>
<response id='handlerA' destination='topic://topicA' >A1</response>
<response id='handlerA' destination='topic://topicA' >B1</response>
<response id='handlerA' destination='topic://topicA' >A2</response>
<response id='handlerA' destination='topic://topicA' >B2</response>
<response id='handlerB' destination='topic://topicB' >A1</response>
<response id='handlerB' destination='topic://topicB' >B1</response>
<response id='handlerB' destination='topic://topicB' >A2</response>
<response id='handlerB' destination='topic://topicB' >B2</response>
</ajax-response>
Further, these messages are constantly re-delivered to the client. (They are never removed from the unconsumedMessages linked list in AjaxListener.)
If https://issues.apache.org/jira/secure/attachment/12467757/all_messages_are_delivered_to_ajax_clients.patch from https://issues.apache.org/jira/browse/AMQ-3094 is applied, the duplication is reduced, but the "id" values for the "topicB" messages are still incorrect.
<ajax-response>
<response id='handlerA' destination='topic://topicA' >A1</response>
<response id='handlerA' destination='topic://topicA' >B1</response>
<response id='handlerA' destination='topic://topicA' >A2</response>
<response id='handlerA' destination='topic://topicA' >B2</response>
</ajax-response>
I've attached a test which demonstrates the problem. This patch will conflict with the one attached to AMQ-3094, but the conflicts should be easy to resolve.