Giter VIP home page Giter VIP logo

Comments (9)

kum-deepak avatar kum-deepak commented on September 23, 2024 2

There is a delay between calling client.activate and the actual connection getting established. You have two options:

  • Write your code inside onConnect. However, onConnect gets called every time a connection is established (like a reconnect after an error).
  • Check for Client#connected before calling publish.

There is wrapper of this library - https://github.com/stomp-js/rx-stomp - that uses rxjs. That wrapper supports local queuing of messages if the underlying connection is not there.

from stompjs.

dibyajyotiron avatar dibyajyotiron commented on September 23, 2024

Cool, onConnect is working but while publishing, how do I check what message I'm publishing? using debug I get only ping pong but not the actual message that I'm publishing.
I want to log the message, where is it available?

onConnect: function(frame) { client.publish({ destination: "/topic/t1", body: "Bla Bla" }); console.log("Client connected to", frame.headers.server); console.log(client); },
I just get the content-length as 7 using debut, but not the actual message from subscriber.

from stompjs.

kum-deepak avatar kum-deepak commented on September 23, 2024

Please try setting https://stomp-js.github.io/api-docs/latest/classes/Client.html#logRawCommunication

from stompjs.

kum-deepak avatar kum-deepak commented on September 23, 2024

This can be set using config as well.

from stompjs.

dibyajyotiron avatar dibyajyotiron commented on September 23, 2024

Thanks for your help. Why is there no disconnected method? I wanted to configure to handle activemq failover after every thing is set up and started and stopping message delivery in case of activemq failover.
maybe something like:
if(client.disconnected) client.reconnect()
so that the publisher doesn't post if my active mq stops responding.

#client.active is something I found but it is not serving my purpose.

from stompjs.

kum-deepak avatar kum-deepak commented on September 23, 2024

reconnectDelay: 5000 in the configuration will trigger automatic reconnect in 5000ms. Please see https://stomp-js.github.io/guide/stompjs/2018/06/28/using-stompjs-v5.html#lifecycle-callbacks for different callbacks. In general this article is a good read.

from stompjs.

dibyajyotiron avatar dibyajyotiron commented on September 23, 2024

reconnectDelay only works if my activemq is not running and I start my producer, it'll tell me it's trying to reconnect. But let's assume a scenario where my activemq is running and my producer is also running and suddenly activemq is stopped. Now the problem is it's trying to reconnect but at the same time it's also publishing to the queue as well.
I need to handle the fail over in a way that once the activemq is disconnected even though publisher is publishing, it should stop publishing and try to reconnect only.

from stompjs.

kum-deepak avatar kum-deepak commented on September 23, 2024

When the broker disconnects for any reason, https://stomp-js.github.io/api-docs/latest/classes/Client.html#onWebSocketClose will be called and https://stomp-js.github.io/api-docs/latest/classes/Client.html#connected will be set to false.

Depending on your application needs I can suggest one of the following:

from stompjs.

dibyajyotiron avatar dibyajyotiron commented on September 23, 2024

Thanks for the replies, for now I've switched to node-stomp and it's working fine for my usage. For my application requirement, stomp-js is not serving my purpose!

from stompjs.

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.