Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-3015

Javascript client does not establish session properly.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.4.1
    • 5.5.0
    • None
    • None
    • Patch Available

    Description

      In some configurations, the javascript client (amq.js) is not loaded from the same container that hosts the activemq broker. For example, we have a Rails app and ActiveMQ both sitting behind apache, and the amq.js file is served directly by apache.

      In these kinds of configurations, when the javascript client first calls amq.init(), there is no JSESSIONID. Both the POST to establish the subscription and the GET to start polling are delivered asynchronously, both without a JSESSIONID, and thus they each end up with different JSESSIONIDS, and the poll never returns any messages (as that session has no subscription).

      This small patch adds support for a callback mechanism that will allow clients to sign up using a callback mechanism that ensures that the JESSIONID is established properly before attempting to make a subscription, like this:

      amq.init({ 
          uri: '/amq',
          sessionInitializedCallback: function() { 
              amq.addListener("display", "topic://sensors", onMessage);       
          } 
      });
      

      The patch is also backwards compatible, so existing code should still work (albeit with the same existing problem).

      Attachments

        1. amq_session.patch
          2 kB
          Pete Schwamb

        Activity

          People

            dejanb Dejan Bosanac
            pschwamb Pete Schwamb
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: