ActiveMQ
  1. ActiveMQ
  2. AMQ-3094

ajax client does not receive all messages

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.4.2
    • Fix Version/s: 5.5.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      OSX 10.6 on MacBook Pro

      java version "1.6.0_20"
      Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
      Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)

      Description

      Not all messages written to a destination are delivered to an ajax client. This seems particularly true if more than 1 message should be returned to a client at once. Often, if 5 messages are available, only the first 1 is actually returned in the <ajax-response> XML. The other 4 are lost.

      Steps to reproduce:

      chat-send.html will send 5 message to topic://CHAT.DEMO. Only 1 (or sometimes 2) messages will be received by the original browser window which is subscribed to the topic. The activemq web admin will verify that 5 messages were actually sent.

        Issue Links

          Activity

          Alex Dean created issue -
          Hide
          Alex Dean added a comment -

          Test file which publishes 5 messages to topic://CHAT.DEMO.

          Show
          Alex Dean added a comment - Test file which publishes 5 messages to topic://CHAT.DEMO.
          Alex Dean made changes -
          Field Original Value New Value
          Attachment chat-send.html [ 12466479 ]
          Hide
          Alex Dean added a comment -

          Attached test case does the following:

          • publishes 3 messages to queue://test
          • subscribes to queue://test using an http POST to the AjaxServlet
          • polls for messages

          The results of the test are inconsistent. Sometimes the client receives all messages, sometimes the client receives 0 messages. (See attached test output in AjaxTest-output.txt.) These results are not consistent with what I'm seeing in JavaScript testing, where I always seem to receive at least one message, but still provide some documentation for the issue.

          Show
          Alex Dean added a comment - Attached test case does the following: publishes 3 messages to queue://test subscribes to queue://test using an http POST to the AjaxServlet polls for messages The results of the test are inconsistent. Sometimes the client receives all messages, sometimes the client receives 0 messages. (See attached test output in AjaxTest-output.txt.) These results are not consistent with what I'm seeing in JavaScript testing, where I always seem to receive at least one message, but still provide some documentation for the issue.
          Alex Dean made changes -
          Attachment AjaxTest.java [ 12466484 ]
          Attachment include-commons-httpclient-in-pom-xml.patch [ 12466485 ]
          Attachment AjaxTest-output.txt [ 12466486 ]
          Hide
          Alex Dean added a comment -

          In AjaxTest-output.txt, also note that for the test runs where no messages are received also show 2 GET requests being made. The test run where all messages are received shows only a single GET request. I'm not sure what that means, given that the test has only a single GET.

          Show
          Alex Dean added a comment - In AjaxTest-output.txt, also note that for the test runs where no messages are received also show 2 GET requests being made. The test run where all messages are received shows only a single GET request. I'm not sure what that means, given that the test has only a single GET.
          Hide
          Alex Dean added a comment -

          I added 1 debugging statement to MessageListenerServlet.writeMessageResponse. (See attached patch & sample output.) The output shows that several individual messages sent from another web client are contained in properties of this single ActiveMQTextMessage. This seems very likely to be the root cause of the problem.

          Is this normal behavior, and we need to search all properties of a TextMessage when writing a response to a client? Or is it that we need to send messages differently so each 'send' POST actually creates a distinct TextMessage?

          Show
          Alex Dean added a comment - I added 1 debugging statement to MessageListenerServlet.writeMessageResponse. (See attached patch & sample output.) The output shows that several individual messages sent from another web client are contained in properties of this single ActiveMQTextMessage. This seems very likely to be the root cause of the problem. Is this normal behavior, and we need to search all properties of a TextMessage when writing a response to a client? Or is it that we need to send messages differently so each 'send' POST actually creates a distinct TextMessage?
          Alex Dean made changes -
          Attachment write_message_response_debugging.patch [ 12466850 ]
          Attachment write_message_response_debugging_output.txt [ 12466851 ]
          Bosanac Dejan <dejanb@apache.org> committed de66445d582033420ef873d1013b70f27e481909 (1 file)
          Hide
          Dejan Bosanac added a comment -

          Fixed with svn revision 1052259.

          The problem was that messages received between POST and GET calls were ignored. That should be fixed now. I modified a provided test a bit to demonstrate this issue every time.

          Thanks for the great work!

          Show
          Dejan Bosanac added a comment - Fixed with svn revision 1052259. The problem was that messages received between POST and GET calls were ignored. That should be fixed now. I modified a provided test a bit to demonstrate this issue every time. Thanks for the great work!
          Dejan Bosanac made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Dejan Bosanac [ dejanb ]
          Fix Version/s 5.5.0 [ 12315626 ]
          Resolution Fixed [ 1 ]
          Hide
          Alex Dean added a comment -

          Dejan: Take a look at the message properties in https://issues.apache.org/jira/secure/attachment/12466851/write_message_response_debugging_output.txt. There are four messages here, but only 1 of them gets delivered.

          The interesting bits are these:
          message=<message type="chat" from="test-user">message two</message>
          text = <message type="chat" from="test-user">message five</message>
          destination = topic://CHAT.DEMO
          m1=<message type="chat" from="test-user">message three</message>
          m2=<message type="chat" from="test-user">message four</message>
          m3=<message type="chat" from="test-user">message five</message>
          t1=send
          t3=send
          t2=send
          d1=topic://CHAT.DEMO
          d2=topic://CHAT.DEMO
          d3=topic://CHAT.DEMO

          When an ajax client sends many messages in a short amount of time, they are then delivered to other clients in a single ActiveMQTextMessage. writeMessageResponse() doesn't handle this properly, and only delivers one of the messages to a subscriber.

          I'm not sure if this is a problem on the sending or receiving side. (Is it legitimate to have multiple messages piled into a single ActiveMQTextMessage like this?) I agree the junit test now passes, but I don't think the issue is resolved yet. I'll work on getting some more tests created which reproduce this issue. For now, you should be able to reproduce it using the chat-send.html script I've already attached to the ticket.

          Show
          Alex Dean added a comment - Dejan: Take a look at the message properties in https://issues.apache.org/jira/secure/attachment/12466851/write_message_response_debugging_output.txt . There are four messages here, but only 1 of them gets delivered. The interesting bits are these: message=<message type="chat" from="test-user">message two</message> text = <message type="chat" from="test-user">message five</message> destination = topic://CHAT.DEMO m1=<message type="chat" from="test-user">message three</message> m2=<message type="chat" from="test-user">message four</message> m3=<message type="chat" from="test-user">message five</message> t1=send t3=send t2=send d1=topic://CHAT.DEMO d2=topic://CHAT.DEMO d3=topic://CHAT.DEMO When an ajax client sends many messages in a short amount of time, they are then delivered to other clients in a single ActiveMQTextMessage. writeMessageResponse() doesn't handle this properly, and only delivers one of the messages to a subscriber. I'm not sure if this is a problem on the sending or receiving side. (Is it legitimate to have multiple messages piled into a single ActiveMQTextMessage like this?) I agree the junit test now passes, but I don't think the issue is resolved yet. I'll work on getting some more tests created which reproduce this issue. For now, you should be able to reproduce it using the chat-send.html script I've already attached to the ticket.
          Alex Dean made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          Alex Dean added a comment -

          Attached test shows that an ajax client will miss messages which arrive while an ajax poll request is in progress.

          This test uses org.eclipse.jetty.client.HttpClient rather than org.apache.commons.httpclient.HttpClient. I was able to get session handling working with the Jetty HttpClient, and it's much better at async requests than the commons HttpClient.

          I sometimes see an org.eclipse.jetty.io.EofException in the poll request. The cause is unclear. Sometimes the error disappears simply by re-running the test. Sometimes doing a recompile of activemq-trunk/activemq-web and then re-running the test causes the error to disappear.

          Show
          Alex Dean added a comment - Attached test shows that an ajax client will miss messages which arrive while an ajax poll request is in progress. This test uses org.eclipse.jetty.client.HttpClient rather than org.apache.commons.httpclient.HttpClient. I was able to get session handling working with the Jetty HttpClient, and it's much better at async requests than the commons HttpClient. I sometimes see an org.eclipse.jetty.io.EofException in the poll request. The cause is unclear. Sometimes the error disappears simply by re-running the test. Sometimes doing a recompile of activemq-trunk/activemq-web and then re-running the test causes the error to disappear.
          Alex Dean made changes -
          Attachment test_shows_that_ajax_client_misses_messages_which_arrive_while_poll_is_in_progress.patch [ 12467569 ]
          Hide
          Alex Dean added a comment -

          Sample test output showing the presence/absence of the EofException I noted.

          Show
          Alex Dean added a comment - Sample test output showing the presence/absence of the EofException I noted.
          Alex Dean made changes -
          Attachment AjaxTest-output-eof-exception.txt [ 12467570 ]
          Attachment AjaxTest-output-no-eof-exception.txt [ 12467571 ]
          Attachment AjaxTest-output-notes.txt [ 12467572 ]
          Hide
          Alex Dean added a comment -

          Patch will allow an ajax client to receive all messages. Several other tests are included for previously-untested ajax code.

          The following tests fail w/o the patch:
          testAjaxClientReceivesMessagesWhichAreSentToQueueWhileClientIsPolling
          testAjaxClientReceivesMessagesWhichAreSentToTopicWhileClientIsPolling
          testStompMessagesAreReceivedByAjaxClient

          Show
          Alex Dean added a comment - Patch will allow an ajax client to receive all messages. Several other tests are included for previously-untested ajax code. The following tests fail w/o the patch: testAjaxClientReceivesMessagesWhichAreSentToQueueWhileClientIsPolling testAjaxClientReceivesMessagesWhichAreSentToTopicWhileClientIsPolling testStompMessagesAreReceivedByAjaxClient
          Alex Dean made changes -
          Alex Dean made changes -
          Attachment AjaxTest-output-eof-exception.txt [ 12467570 ]
          Alex Dean made changes -
          Attachment AjaxTest-output-no-eof-exception.txt [ 12467571 ]
          Alex Dean made changes -
          Attachment AjaxTest-output-notes.txt [ 12467572 ]
          Alex Dean made changes -
          Attachment AjaxTest-output.txt [ 12466486 ]
          Alex Dean made changes -
          Attachment AjaxTest.java [ 12466484 ]
          Alex Dean made changes -
          Attachment test_shows_that_ajax_client_misses_messages_which_arrive_while_poll_is_in_progress.patch [ 12467569 ]
          Alex Dean made changes -
          Attachment write_message_response_debugging.patch [ 12466850 ]
          Alex Dean made changes -
          Attachment write_message_response_debugging_output.txt [ 12466851 ]
          Hide
          Alex Dean added a comment -

          Updated my svn working copy & re-generated patch due to request from Jeff Rose. Now based on trunk r1057227.

          Show
          Alex Dean added a comment - Updated my svn working copy & re-generated patch due to request from Jeff Rose. Now based on trunk r1057227.
          Alex Dean made changes -
          Attachment all_messages_are_delivered_to_ajax_clients.2.patch [ 12467891 ]
          Hide
          Alex Dean added a comment -

          Updated my svn working copy & re-generated patch due to request from Jeff Rose. Now based on trunk r1057227. Previous version of this patch (w/ identical file name) was missing 1 test which should not have been omitted.

          Show
          Alex Dean added a comment - Updated my svn working copy & re-generated patch due to request from Jeff Rose. Now based on trunk r1057227. Previous version of this patch (w/ identical file name) was missing 1 test which should not have been omitted.
          Alex Dean made changes -
          Alex Dean made changes -
          Attachment all_messages_are_delivered_to_ajax_clients.2.patch [ 12467891 ]
          Alex Dean <alexd@apache.org> committed 88fc7fec5091ae36d5ceb05203577dd3875dee14 (5 files)
          Reviews: none

          https://issues.apache.org/jira/browse/AMQ-3094 - ajax does not receive all messages * ensure delivery of messages received by AjaxListener when a continuation is not available for resumption. * add test coverage for several common uses of AjaxServlet * switch back to jetty httpclient for better processing of asynchronous HTTP
          git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1064725 13f79535-47bb-0310-9956-ffa450edef68

          Hide
          Alex Dean added a comment -

          Resolved in svn revision 1064725.

          Show
          Alex Dean added a comment - Resolved in svn revision 1064725.
          Alex Dean made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Edmond Kemokai made changes -
          Link This issue is cloned as AMQ-3585 [ AMQ-3585 ]
          Geert Pante made changes -
          Link This issue is depended upon by AMQ-5182 [ AMQ-5182 ]

            People

            • Assignee:
              Dejan Bosanac
              Reporter:
              Alex Dean
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development