You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Ken Seiss (JIRA)" <ji...@apache.org> on 2011/06/02 16:13:47 UTC
[jira] [Created] (AMQ-3350) amq.js initHandler() method swallows
first message received
amq.js initHandler() method swallows first message received
-----------------------------------------------------------
Key: AMQ-3350
URL: https://issues.apache.org/jira/browse/AMQ-3350
Project: ActiveMQ
Issue Type: Bug
Components: JMS client
Affects Versions: 5.5.0
Environment: MAC OS X (10.6)
Reporter: Ken Seiss
The very first message received by a javascript client (when using {{amq.js}}) is swallowed with no action. This is because the {{sendPoll()}} method calls {{initHandler()}} from the {{successCallback}} handler when the message arrives and the boolean {{sessionInitialized}} is false. This sends the code into the {{initHandler()}} method which in the end just calls {{sendPoll()}} again. It never bothers calling {{pollHandler()}} to deal with the message it received.
{code:title=amq.js|borderStyle=solid}
// *** This method does not process the data passed in. It just calls sendPoll() again!
var initHandler = function(data) {
sessionInitialized = true;
if(sessionInitializedCallback) {
sessionInitializedCallback();
}
sendPoll();
}
var sendPoll = function() {
// Workaround IE6 bug where it caches the response
// Generate a unique query string with date and random
var now = new Date();
var timeoutArg = sessionInitialized ? timeout : 0.001;
var data = 'timeout=' + timeoutArg * 1000
+ '&d=' + now.getTime()
+ '&r=' + Math.random();
var successCallback = sessionInitialized ? pollHandler : initHandler;
var options = { method: 'get',
data: addClientId( data ),
success: successCallback,
error: pollErrorHandler};
adapter.ajax(uri, options);
};
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (AMQ-3350) amq.js initHandler() method swallows
first message received
Posted by "Ken Seiss (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AMQ-3350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13042871#comment-13042871 ]
Ken Seiss commented on AMQ-3350:
--------------------------------
A fix that is working for me is to change the {{sendPoll();}} call in {{initHandler()}} to {{pollHandler(data);}}
My method now looks like this and it is working as expected:
{code:title=amq.js|borderStyle=solid}
var initHandler = function(data) {
sessionInitialized = true;
if(sessionInitializedCallback) {
sessionInitializedCallback();
}
//sendPoll();
pollHandler(data);
}
{code}
> amq.js initHandler() method swallows first message received
> -----------------------------------------------------------
>
> Key: AMQ-3350
> URL: https://issues.apache.org/jira/browse/AMQ-3350
> Project: ActiveMQ
> Issue Type: Bug
> Components: JMS client
> Affects Versions: 5.5.0
> Environment: MAC OS X (10.6)
> Reporter: Ken Seiss
>
> The very first message received by a javascript client (when using {{amq.js}}) is swallowed with no action. This is because the {{sendPoll()}} method calls {{initHandler()}} from the {{successCallback}} handler when the message arrives and the boolean {{sessionInitialized}} is false. This sends the code into the {{initHandler()}} method which in the end just calls {{sendPoll()}} again. It never bothers calling {{pollHandler()}} to deal with the message it received.
> {code:title=amq.js|borderStyle=solid}
> // *** This method does not process the data passed in. It just calls sendPoll() again!
> var initHandler = function(data) {
> sessionInitialized = true;
> if(sessionInitializedCallback) {
> sessionInitializedCallback();
> }
> sendPoll();
> }
> var sendPoll = function() {
> // Workaround IE6 bug where it caches the response
> // Generate a unique query string with date and random
> var now = new Date();
> var timeoutArg = sessionInitialized ? timeout : 0.001;
> var data = 'timeout=' + timeoutArg * 1000
> + '&d=' + now.getTime()
> + '&r=' + Math.random();
> var successCallback = sessionInitialized ? pollHandler : initHandler;
>
> var options = { method: 'get',
> data: addClientId( data ),
> success: successCallback,
> error: pollErrorHandler};
> adapter.ajax(uri, options);
> };
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira