kubemq-io / kubemq-CSharp

C# Library for KubeMQ server
MIT License
30 stars 8 forks source link

Queue.Pull() and Transaction.Receive() do not return immediately when the queue is empty and the waitingSecond = 0 #8

Closed francotiveron closed 1 year ago

francotiveron commented 2 years ago

F# code excerpt

        let sw = Stopwatch()
        let q = Queue.Queue(queue, clientId, url, Log, WaitTimeSecondsQueueMessages = 0) 
        sw.Start()
        let pu = q.Pull(1, 0)
        sw.Stop()
        Log.d sw.ElapsedMilliseconds

The printout is always > 1000 when the queue is empty. I would expect to be 0 (edited)

kubemq commented 2 years ago

What are the parameters you are sending on the pull ? Auto Ack is true ? the default is false,

On Mon, Jan 3, 2022 at 8:46 AM Franco Tiveron @.***> wrote:

F# code excerpt

    let sw = Stopwatch()
    let q = Queue.Queue(queue, clientId, url, Log, WaitTimeSecondsQueueMessages = 0)
    sw.Start()
    let pu = q.Pull(1, 0)
    sw.Stop()
    Log.d sw.ElapsedMilliseconds

The printout is always > 1000 when the queue is empty. I would expect to be 0 (edited)

— Reply to this email directly, view it on GitHub https://github.com/kubemq-io/kubemq-CSharp/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK5WGXC2TIOFXGS3USOTG3TUUFA33ANCNFSM5LET63WQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

francotiveron commented 2 years ago

The Pull method has only 2 parameters

Pull(maxPullMessages: int, waitTimeoutSeconds: int)

What is Auto Ack? there is no mention in the .NET SDK

There is an entire namespace QueueStream in the SDK , but no documentation and not examples in the cookbook. Maybe you intent that one. Are there examples on how to use it outside of the cookbook repo?

francotiveron commented 2 years ago

@kubemq I downloaded the repo and made some tests using the QueueStream API (see code below).

The result is the same, WaitTimeout 0 is not honoured, response never comes back quicker than 1s, regardless the value of AutoAck

let queue = "q-1"
let url = "localhost:50000"

let w = QueueStream(url, "writer")

let m1 = Message(
    Queue = queue
    , Body = Tools.Converter.ToByteArray "message-1"
    , Metadata = "meta-1"
) 

let sendRequest = SendRequest(ResizeArray([m1]))

let sendResponse = w.Send(sendRequest).Result

let r = QueueStream(url, "reader")

let pollRequest = PollRequest(Queue = queue, WaitTimeout = 0, MaxItems = 1, AutoAck = true)

let sw = Stopwatch()
sw.Start()
let pollResponse = r.Poll(pollRequest).Result
sw.Stop()
kubemq commented 1 year ago

Please use the QueueStream implementation