GithubHelp home page GithubHelp logo

Connection#poll doesnt work about stomp HOT 3 CLOSED

stompgem avatar stompgem commented on June 21, 2024
Connection#poll doesnt work

from stomp.

Comments (3)

gmallard avatar gmallard commented on June 21, 2024

I believe the behavior is expected.

You have issued connect, and subscribe, but the broker has not had time (yet) to get data on the wire and have it physically available to the client. Specifically the socket is returning false to 'socket.ready?'. It means there is nothing (yet) to be received, i.e nothing in the socket's input buffers.

I understand that the 'queue already has messages on it'. But in your example, the first one is still in flight from the server to the client.

Note that this can even occur when the client and broker are resident on the same system.

I would normally use poll something like this:

while true
    message = conn.poll
    if message
        # process message
    else
        sleep x
    end
end

The point of poll is that it is asynchronous (non-blocking). If there is nothing to receive, you can go and attend to other required tasks, or sleep to wait for a message to arrive.

If you want a synchronous (blocking) receive, then ask for one:

message = conn.receive

from stomp.

gmallard avatar gmallard commented on June 21, 2024

For completeness, I am going to document that 'poll' is indeed broken using JRuby. And it will remain broken until the JRuby team addresses this:

http://jira.codehaus.org/browse/JRUBY-5617

from stomp.

ripienaar avatar ripienaar commented on June 21, 2024

Yeah I too prefer receive, but had to play with poll and noticed the odd behavior.

Thanks for the great description of whats going on though, much appreciated. I was going to file some jruby issues but I guess there's little point :)

You can close this, thanks!

from stomp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.