I am trying to figure what could be the flow since I am using JMS for the first time. Locally, I have ApacheMQ installed on my Windows Machine. And using this simple Spring JMS example mentioned here, I was able to see how to send and receive message thing works in Spring JMS and my ApacheMQ looks like the following after running the producer and consumer:
Here is my sender class :
public class Sender {
private static final Logger LOGGER =
LoggerFactory.getLogger(Sender.class);
@Autowired
private JmsTemplate jmsTemplate;
public void send(String message) {
LOGGER.info("sending message='{}'", message);
jmsTemplate.convertAndSend("Testing Spring JMS", message);
}
}
Here is my Receiver class :
public class Receiver {
private static final Logger LOGGER =
LoggerFactory.getLogger(Receiver.class);
private CountDownLatch latch = new CountDownLatch(1);
public CountDownLatch getLatch() {
return latch;
}
@JmsListener(destination = "Testing Spring JMS")
public void receive(String message) {
LOGGER.info("received message='{}'", message);
latch.countDown();
}
}
So, now in my User Interface, I have a "Download" button somewhere and when a user clicks on it, it is supposed to call a stored procedure which is going to take time.
I am trying to understand, how would I call this JMS application when a user clicks on the download button so that I could send the stored procedure call to the Sender. I mean there is no endpoint defined in the code above just like if we were to use a REST, the request would be hitting Controller.
And how would sender be sending it to the destination queue, in the form of a string message just like shown in the example above?
I guess if I would have a clear idea about sender processing this, I might get some idea about how the Receiver is going to handle this.