Code Monkey home page Code Monkey logo

Comments (9)

jmesnil avatar jmesnil commented on June 7, 2024

but how do you subscribe to temp queues to receive messages sent on it?

from stomp-websocket.

emile avatar emile commented on June 7, 2024

Implicit subscriptions are created when temporary destinations are used.

from stomp-websocket.

jmesnil avatar jmesnil commented on June 7, 2024

If I understand you correctly, if a client SEND a message with a reply-to header, he is automatically subscribed to this temporary queue.
If this is done automatically on the broker side, I don't see why it'd not work with stomp.js.

from stomp-websocket.

emile avatar emile commented on June 7, 2024

An implicit subscription is set up on the broker if the "reply-to" value starts with "/temp-queue/".

Thanks for suggesting that this already work with stomp.js. Can you confirm which callback will be used to deliver messages that arrive for implicit subscriptions?

from stomp-websocket.

jmesnil avatar jmesnil commented on June 7, 2024

actually, you're right, no callback will be used to deliver the messages.

The issue is in https://github.com/jmesnil/stomp-websocket/blob/master/src/stomp.coffee#L211 where we lookup the callback registered in the subscribe methods. If none is found, the received message is discarded. That's wrong.

One way to get the temp queue working would be to allow the client to define a onreceive(message) callback that will be used if no callback is found in @subscriptions.
Then your code would look like:

var client = Stomp.client(...);
client.onreceive = function(message) {
    // receive message from temp queues
};
client.send(destination, {'reply-to': '/temp-queue/foo'}, "hello");

Would you be up to contribute a patch? :)

from stomp-websocket.

emile avatar emile commented on June 7, 2024

If there is anything that needs to be done on the broker side or testing then I can certainly help with that.

from stomp-websocket.

jmesnil avatar jmesnil commented on June 7, 2024

I've create branch to fix this at https://github.com/jmesnil/stomp-websocket/tree/implicit_subscription_support

Could you try using the corresponding stomp.js and tell me if that allows you to receive message from temp queues?

thanks

from stomp-websocket.

emile avatar emile commented on June 7, 2024

Thanks alot, that appears to work for me.

from stomp-websocket.

jmesnil avatar jmesnil commented on June 7, 2024

I've pushed the commit to stomp.js master.

I also proposed a PR for rabbitmq-web-stomp-examples to demonstrates how to use temporary queues (tested with RabbitMQ 3.1.4): rabbitmq/rabbitmq-web-stomp-examples#3

from stomp-websocket.

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.