File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Mock on JMS and Design Patterns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Mock on JMS and Design Patterns" Watch "Mock on JMS and Design Patterns" New topic
Author

Mock on JMS and Design Patterns

David Follow
Ranch Hand

Joined: Oct 16, 2001
Posts: 223
Hello all,

in a mock test I found the following question:

"...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."

So which one is more correct? Mediator or Bridge?

D.


SCJP, SCEA
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
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 ]

Byron Estes<br />Sun Certified Enterprise Architect<br />Senior Consulant<br />Blackwell Consulting Services<br />Chicago, IL<br /><a href="http://www.bcsinc.com" target="_blank" rel="nofollow">www.bcsinc.com</a>
David Follow
Ranch Hand

Joined: Oct 16, 2001
Posts: 223
Hi Byron,

thanks a lot for your reply.
Can you please list some of the "useful" mocks that you did.
Ideally the ones that are close to the real thing - if such a mock exists at all...

D.
vu lee
Ranch Hand

Joined: Apr 19, 2005
Posts: 189
MQSeries also exhibits some characteristics of mediator too. JMS provides contract that others have to fulfill. Therefore, the preferable answer is bridge.
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
David,

I wish I could help you out, but I did my cert about 2 years ago and I didn't keep all that stuff.

I know there is a company that at the time had a nice little mock test program that I used in beta (...they asked me to review their software/questions and provid comment).

I believe it was WhizLabs. If they are still doing it, they should have improved it greatly by now. You might want to check it out.
Jeremy Hsu
Ranch Hand

Joined: Mar 28, 2005
Posts: 79
I think the key thing that you have to understand is this.

JMS is a specification (JMS is an specification that defined by Sun. It consists of only API. The implementation is left to third party.)

MQSeries is an implementation of JMS


Therefore, bridge is definitely the choice

[ May 17, 2005: Message edited by: Jeremy Hsu ]
[ May 17, 2005: Message edited by: Jeremy Hsu ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Mock on JMS and Design Patterns
 
Similar Threads
Design Pattern vague question
gui problems
A confusing answer...
Need help with Patterns
Design patterns for Web Services