You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I coded a way to subscribe to an MQ queue using rxStomp. I have no problems everything works well but I would like to optimize my treatment by making it responsive and using promises but I am not comfortable with this concept in node.js.
I would like to continue to receive messages and send them to the database. But I would like it to send in database is not blocking and that I continue to receive my MQ messages in the order of arrival.
Could someone - help me? Thanks in advance
This is my code actually
functionrxSubscribeToTopic(){try{rxStomp.connected$.subscribe(()=>{subscription=rxStomp.watch({destination: "/queue/test",'ack': 'client','activemq.prefetchSize': 1}).subscribe(async(message)=>{letclient=createMongoClient();try{awaitclient.connect();constdatabase=client.db("stomp");constcollection=database.collection("stomp_message");letmessageJson={"message": message.body}awaitcollection.insertOne(messageJson).then(value=>console.log("Inserted"+value.insertedId))}finally{// Ensures that the client will close when you finish/error}});})}catch(e){log(e)rxStomp.stompErrors$.subscribe(value=>value.body);activateStomp();}
The text was updated successfully, but these errors were encountered:
I have not tested your code. However, it seems to be doing what you intend. Does it not work as you want it to?
I noticed some other issues with the code. It can be written much simpler. I am ignoring those. I guess that you have written just an outline code in your issue.
For more details what I want it's to make the function watch() reactive too.
actually this code works but i tested with little message.
Will it run with big treatment?
My code is a test code but I’m new to JS if you have advice on my code to optimize it will be happy to take them
I coded a way to subscribe to an MQ queue using rxStomp. I have no problems everything works well but I would like to optimize my treatment by making it responsive and using promises but I am not comfortable with this concept in node.js.
I would like to continue to receive messages and send them to the database. But I would like it to send in database is not blocking and that I continue to receive my MQ messages in the order of arrival.
Could someone - help me? Thanks in advance
This is my code actually
The text was updated successfully, but these errors were encountered: