This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You are designing an online shopping application to make it easier for customers to order products from your company. The aim is that the majority of customers buying over the telephone will start using the web instead. When customers purchases goods online they will use credit cards and will require an instant response as to whether the sale has been approved or not. (Note that the credit card validation is carried out by another very powerful system.)
What type of messaging should be used?
Choose one answer.
a. Synchronous messaging
b. Asynchronous messaging
c. You shouldn't be using messaging at all as its not transactional.
d. You could use messaging because it is transactional however it is not advised, as the system would never perform well enough for an instant response.
I would say option d. But as usual the authors of mock feel option a.
"Choice A is correct.
Synchronous messaging provides an instant response and is therefore the right answer. It is always arguable as to whether messaging should be used if you require an instant response but if you do decide to use messaging then you should always use synchronous messaging when needing an instant response.
Choice B is incorrect because asynchronous messaging does not provide an instant response. You can make messaging transactional by creating your own transactions in your code. Hence, choice C is incorrect.
Choice D is arguable too, but it is not the most appropriate answer because the question suggests that the system the messages will be sent to is very powerful and will be able to cope with the volume of traffic. Therefore, choice D would be incorrect as it suggests that the system will not perform well enough for an instant response. "
In this case, I understand the answer (although I symphatise with your frustration). The correct answer is "A", because of the giveaway 'immediate response' and the incorrectness of the other options:
asynchronous messaging is wrong here (see above)
C/D is wrong, because MDBs CAN BE transactional, but this is not necessarily the case, and messaging in itself is unrelated to transactional issues: this is a matter of implementation