"...for asynchronous communication A communicates with B using JMS and MQSeries. Which design pattern describes the use of JMS the best."
Possible answers amongst others: Mediator or Bridge
I thought it's Mediator but the correct answer is Bridge.
Thinking about it, it makes total sense since some J2EE APIs such as JDBC, JNDI and JMS use the bridge patterns to bridge to the providers implementation. However, Mediator does exactly what JMS does: "Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently."
Bridge Decouple an abstraction from its implementation so that the two can vary independently
Mediator Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
* Definitions are from "Elements of Reusable Object-Oriented Software" - Gof4
I agree with you that JMS exhibits some of qualities of a Mediator, but it also exhibits qualities from a number of other patterns too.
The key here is that JMS can sit over top of any number of implementations. They mention MQSeries, but it could be SonicMQ or any other product that provides message queing.
JDBC is a bridge too...You've probably even heard people refer to the JDBC/ODBC bridge, right.
There is no doubt that these questions can be tricky. They are intentionally made to be so. When I took the exam I can remember marking half a dozen that I had to go back to after I finished all the others and try to second guess what they were asking or what tricks they were trying to play. I changed a few and got lucky, I had a 100% on Part I. Keep on doing the mock exams. I went through a lot of them. Keep questioning the answers, it helps you to more fully understand the subject matter.
Good luck! [ May 11, 2005: Message edited by: Byron Estes ]