Yes, it looks like this can be an acceptable workaround until amq.js is
fixed.  The trick is to use something like ExtJS' Ext.Loader.loadScript()
function to bring in a second or third or fourth copy of amq.js, then
encapsulate it in a function.  Here's what's working for me:

function startAMQ () {
        Ext.Loader.loadScript({
                url:
'https://spire.spirebps.com:4444/SpireDev/SpireRoot/Shared/amq/js/amq_jquery_adapter.js',
                scope: this,                   // scope of callbacks
                onLoad: function() {           // callback fn when script is 
loaded
                        Ext.Loader.loadScript({
                                url:
'https://spire.spirebps.com:4444/SpireDev/SpireRoot/Shared/amq/js/amq.js',
                                scope: this,                   // scope of 
callbacks
                                onLoad: function() {           // callback fn 
when script is loaded
                                        // AMQ : Initialize AMQ connection
                                                var amq = this.org.activemq.Amq;

                                                try {
                                                        amq.init({
                                                                uri: 
'https://spire.spirebps.com:8162/demo/amq',
                                                                logging: true,
                                                                timeout: 20,
                                                                clientId: (new 
Date()).getTime().toString()
                                                        });
                                                } catch (e) {
                                                        alert("AMQ 
initialization error: " + e);
                                                }

                                        amq.addListener('testconnection2', 
'topic://MyApp/Simulator',
myHandler.rcvMessage);
                                },
                                onError: function() {          // callback fn 
if load fails 
                                        alert("Error while loading amq.js for 
AMQ2");
                                } 
                        });
                },
                onError: function() {          // callback fn if load fails 
                        alert("Error while loading amq_jquery_adapter for 
AMQ2");
                } 
        });
};

startAMQ1();


Hope this helps others faced with the same problem.

Bill



--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Possible-Bug-in-AJAX-MessageListenerServlet-java-tp4672543p4672749.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to