Link to home
Create AccountLog in
Avatar of Los Angeles1
Los Angeles1

asked on

JMS synchronous and Asynchronous

In the context of JMS, what is the difference beween messages being sent synchronously and asynchronously

Are different calls involved

Thanks
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
The above answer is actually not quite what you want. You ask about message being SENT, whereas girionis has provided information about RECEIVING messages. See the comment I posted on your other questions about this!
I think my answer is correct. I answered explicitly what happens when you sent messages synchronously and asynchronously and how the flow works in both cases. Explicitly I also answered what happens when you receive messages. How would you answer the question? I am just curious to see why you believe my answer is wrong.
I don't think your answer is in itself wrong! :)  Just not the answer to the question asked.

From the original question,
what is the difference beween messages being sent synchronously and asynchronously
As I said, fairly obviously, in my comment above, the question is about how messages are SENT not about how they are received, so talking about MessageListener's, MessageConsumer's, onMessage() methods or receive() methods, has no bearing on the actual question being asked. They have no influence on how messages are actually sent! Indeed, it is quite possible that a certain application only ever "sends" messages to a broker, and therefore doesn't even contain a line of code that implements onMessage() or calls receive(). Yet it still may be concerned with how messages are sent to the broker, either syncronous or asynchronous.

As I hinted, more to the original question author, that in his other question I explain how the method of sending messages to the broker is a controlled by the actual JMS provider, and there is no way to DIRECTLY affect whether the messages are sent sync/async. There is certainly not "different calls involved" as asked in the original question.


I answered explicitly what happens when you sent messages synchronously and asynchronously and how the flow works in both cases
Firstly, the fact that you said this shows that you don't understand how the messages are sent, ie. that you have no direct control over the method used to send them. And secondly, even claiming that you did this is a stretch as you only had one sentence related to message sending... quote "You send messages to the queue and you forget about them". Everything else is related to message recpetion!

Explicitly I also answered what happens when you receive messages
I agree that you did this, but as I said, it wasn't the question that was asked.


I don't mean to offend, Girionis, I am just trying to make sure Greensburo is not unduly confused by the two, totally separate and unrelated, aspects of message sending and recpetion in JMS.
mccarl no offense taken, the purpose of this site is exactly this, the exchange (of knowledge I'd say).

To the topic now. I see your point and I agree, that technically it might not be the answer to the exact question the user asked, because you indeed cannot control the way the messages are sent. But this is just technicality, and I will explain why with a simpler example.

Lets say that someone in this site asks how you can do garbage collection manually. I could answer that you either call the System.gc() or Runtime.getRuntime().gc(). Is my answer wrong? Well, technically it is, since even if you call these methods the JVM does not guarantee that it will perform a garbage collection. But essentially my answer is correct since the only way to (have a chance to) manually perform a garbage collection is through these two methods.

I reckon the same principle applies to the question the user asked.