Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    RPCManager.sendQueue(new RPCQueueCallback()) never calls the callback

    Hi,

    SmartClient Version: v9.1p_2014-07-12/Pro Deployment (built 2014-07-12)

    Somewhere, we start a Queue and use a callback on SendQueue to know when it's done. Deeper logic might call server in that Queue.
    Sometimes though, the Queue doesn't do anything (because the server call isn't needed because the response is already cached in client).

    In that scenario, sendQueue just returns false, without notifying the callback.

    Code:
        sendQueue : function (callback, prompt, URL, delay) {
            var transaction = this.currentTransaction;
    
            // we're going to submit this transaction or error out in some way - in either way we're not
            // going to continue queueing
            this.currentTransaction = null;
            this.queuing = false;
    
            if (!transaction) {
                //>DEBUG Note this can happen easily if rpcRequests have been deferred because they
                // are attempted before page load.
                this.logInfo("sendQueue called with no current queue, ignoring");
                //<DEBUG
                return false;
            }
            if (delay) this.delayCall("_sendQueue", [callback,prompt,URL,transaction]);
            else return this._sendQueue(callback,prompt,URL,transaction);
        },

    The "return false" doesn't make it to SmartGWT, since it's only void :: public static native void sendQueue(RPCQueueCallback callback)

    Can you maybe call the callback with "null" responses in that if (!transaction) ?
    Or use the return boolean result in SmartGWT?



    I could have tried checking if there is a transaction too, but this will probably yield a nullpointer in that case:
    Code:
        public static native int getCurrentTransactionIdAsInt() /*-{
            return $wnd.isc.RPCManager.getCurrentTransactionId();
        }-*/;
    Since that returns an "int", but in JavaScript it can return "null".
    Code:
        getCurrentTransactionId : function () {
            return this.currentTransaction ? this.currentTransaction.transactionNum : null;
        },


    TIA

    #2
    Calling getCurrentTransactionId() via JSNI will not crash and that's a reasonable way to do it.

    We'll also add a separate method to getQueueTransactionId(), explicitly doc that it returns null if there's no queued requests, and interlink the docs (for 5.0).

    Comment


      #3
      Great, thanks.

      I solved it locally too: I did something like that with JSNI - I checked if getCurrentTransactionId is null.
      But then I still have to call sendQueue() to make sure the "this.queuing = false;" is done. Otherwise any other transaction following on this will think it's in a queue and will wait forever.

      I searched the code for something that unsets "this.queuing". Maybe you can add an explicit method for that as well, as even cancelQueue() doesn't do this.

      Comment


        #4
        If you've got yourself in a coding situation where you don't know whether you've sent something or not, calling sendQueue() to make sure is fine. It does not log warnings or throw exceptions if there are no queued requests.

        Comment

        Working...
        X