kaazing / javascript.client

Apache License 2.0
21 stars 16 forks source link

rejectBasic and qosBasic don't work #5

Open sbadugu opened 9 years ago

sbadugu commented 9 years ago

From @bradjorgensen on March 2, 2015 19:21

rejectBasic() doesn't work because it is in the wrong state array in AmqpClient.js. It is in the array for synchronous methods but it is asynchronous so it throws an error.
qosBasic doesn't work because it is not in any of the state arrays in AmqpClient.js. I am working on a patch to fix these issues.

Copied from original issue: kaazing/kaazing-amqp-0-9-1-client-javascript#16

sbadugu commented 9 years ago

From @brennangaunce on March 25, 2015 3:10

qosBasic was verified using a locally build kaazing-amqp-0-9-1-client-javascript with the proposed fix.

For rejectBasic, when requeue is set to false in the rejectBasic Config:

var rejectConfig = {deliveryTag: dt, requeue: false};

The same messages keep getting redelivered to the same client when they shouldn't be.

From Shuaib: Client technology: JavaScript Browser with Version: Firefox 35.0.1 Client O/S with Version: OS X 10.10 Gateway with version: 4.0.6.57 Message Broker: Qpid Java Broker 0.28 Can the bug be reproduced in a Kaazing demo out-of-the-box? Yes Is this a regression from previous released version? Yet to be tested Gateway config: Right out-of-the-box Client code to reproduce: Modify setTimeout in handleMessageReceived to call rejectBasic, instead of ackBasic as is done in this snippet:

var handleMessageReceived = function(event) {
    receivedMessageCount.text(++receivedMessageCounter);
    var body = null;

    // Check how the payload was packaged since older browsers like IE7 don't
    // support ArrayBuffer. In those cases, a Kaazing ByteBuffer was used instead.
    if (typeof(ArrayBuffer) === "undefined") {
        body = event.getBodyAsByteBuffer().getString(Charset.UTF8);
    }
    else {
        body = arrayBufferToString(event.getBodyAsArrayBuffer())
    }
    var props = event.properties;
    var exchange = event.args.exchange;
    var routingKey = event.args.routingKey;
    var dt = event.args.deliveryTag;
    var channel = event.target;

    logMessageDiv("MESSAGE CONSUMED: ", "receiveMessage", body, props, exchange, routingKey);

    // Acknowledge the message as we passed in a false for 'noAck' in the
    // AmqpChannel.consumeBasic() call. If the message is not acknowledged,
    // the broker will keep holding the message. And, as more and more
    // messages are held by the broker, it will eventually result in
    // an out of memory error.
    var config = {deliveryTag: dt, multiple: true};

    setTimeout(function() {
        // Acknowledging is a synchronous call with a roundtrip to the server,
        // therefore schedule it independently so as not to block current
        // execution.
        // channel.ackBasic(config);
        var rejectConfig = {deliveryTag: dt, requeue: true};
        channel.rejectBasic(rejectConfig);
    }, 0);
}

If requeue is set to false the message is still redelivered, but should not be.