You don’t talk to an MQ through the frontend, this is something that should be entirely opaque to the client and handled by the backend. You would hit a normal Java API endpoint, then if the Java server decides that it needs to put something in or take something out of your MQ, then it does. The client doesn’t care and shouldn’t know this is happening.
If you’re working with a Node application that isn’t talking to the MQ directly and needs to go through a Java service, then it’s the same thing. Otherwise, you would try to find an implementation for whatever your MQ service is for Node.
I see. I have a small JMS hello world going on in my Java World and on Apache MQ it looks like the following:
I followed the example mentioned here :
From client, I need to send some parameters to the backend. And those parameters are supposed to be the required parameters for the stored procedure that I am going to schedule on the MQ.I am wondering , in this scenario,how would the backend be accepting these parameters since this isn’t a REST based request where I could call a webservice using Ajax call. Do you think something like this(http://activemq.apache.org/ajax.html) would be used in this case?
how would the backend be accepting these parameters since this isn’t a REST based request where I could call a webservice using Ajax call.
You build a REST endpoint to accept the parameters. There’s no other option. You can only AJAX/Fetch from the frontend.
I see. So, I am wondering , if in this scenario of building REST end point, if following could create any problem:
Suppose, I have a REST end point, UI sends the parameter to backend, backend calls a stored procedure with the parameters received and put the stored procedure call to the JMS queue since it’s going to take hours… At the same time, if someone from the UI sends more parameters to the back end, and if there’s a need to call the same stored procedure again, would this be any issue because the previous request is still in process? Basically, I am talking about asynchronous behavior here.
Yeah, it could cause a issues. You more or less described the reason why a targeted DDoS attack is hard to prevent. It’s just something you’re going to have to handle on your backend and will depend on the specific system. But, your logic is right for how it should work.
Ok. By the way I am trying to understand one thing. A simple REST call follow the following pattern:
Request comes to a REST end point with parameters.
An interface (data access object) contains unimplemented methods.
A data access object implementation is where communication with the database happens.
Now, in the scenario where I am using JMS, could you throw some light on what exactly I need to move to the JMS queue so that the call to the stored procedure which is going to take lot of time is scheduled somehow via JMS so that if a user sends out another set of paremeters after first request, I could schedule it in the JMS Queue after the first one. So far, I have only seen examples of JMS where a string of message is sent to JMS Queue by producer and same message is consumed by the consumer.
But in the scenario, where I need to put the call to a stored procedure on to a JMS queue, I am wondering what exactly I should be sending. Any inputs/thoughts on this are appreciated.Thanks