aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Part 1 - JMS question from Mock Exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Part 1 - JMS question from Mock Exam" Watch "Part 1 - JMS question from Mock Exam" New topic
Author

Part 1 - JMS question from Mock Exam

A.G. Arun
Greenhorn

Joined: Jan 10, 2006
Posts: 7

A company is in the business of online sales. They focus on high-end cameras and lenses. The online line web application is written using a Java EE technology stack. A consumer starts a transaction to purchase a camera and the result is that a transaction attempts to insert into the inventory database using JDBC and then sends a message to a message-driven bean over a transactional JMS queue. When the message is received by the message-driven bean, it attempts an insert into the sales database using JDBC.


Which statement cannot be a valid outcome of this transaction?
A. The message-driven bean does not perform an insert, the application does not perform an insert.
B. The message-driven bean performs an insert, the application performs an insert.
C. The message-driven bean does not perform an insert, the application performs an insert.
D. The message-driven bean performs an insert, the application does not.



Answer:
Option D is correct.
Options A, D, C are all possible outcomes of this transaction.

Clearly Answer has a typo and the correct answer is either B or D. However, I was inclined towards C. Any thoughts/explanations/interpretations ? Thanks.


Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
The Insert done by the Application and putting the message on the queue can happen in one transaction and the insert done by Message Driven Bean is a separate transaction all together.

If the insert in the database does not happen from the application the message will not be put on the queue as both of them happen in same transaction.

D can never happen and is not a Valid outcome and Hence the answer. Reason. If insert fails no message will be put on the queue and hence nothing will be received by the MDB.

A, B and C are all valid..

Explanations are as below.

A: Insert does not happen from the application and no message will be put on the queue, therefore no message will be received by MBD and no insert will happen
B: Most ideal scenario where both the transactions (Transaction 1: application Db insert , Put message on queue) and (Transaction 2: Dequeue message from Queue by MDB and insert into Database by MDB).. Well Dequeing by MDB and DB insert may or maynot happen in same transaction depending on the type of bean's transaction (BMT or CMT), thats a different story altogether..
C: Most undesirable scenario but possible as the Insert into DB by MDB is a different transaction.

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11277
    
  59

Please post the name of the mock exam you are getting the question from. Not only is it polite to mention your sources, failure to do so can result in your post being deleted for failing to meet our position on real questions.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
A.G. Arun
Greenhorn

Joined: Jan 10, 2006
Posts: 7
Thanks Amol. Your explanation helps.

Question source: practice exam from Sun - link
Gladwin Burboz
Greenhorn

Joined: Feb 26, 2008
Posts: 25

There are two transactions happening here
T1: The application performs an insert (inventory database), then put message on JMS
T2: The message-driven bean performs an insert (sales database), using JMS message from the queue



A. The message-driven bean does not perform an insert, the application does not perform an insert.

VALID:
T1: T1 insert fails then T1 rolls back, so message is put and appears on queue
T2: Message will not be available to T2, so no insert will happen


B. The message-driven bean performs an insert, the application performs an insert.

VALID:
T1: T1 insert successfully completes, so message is put and appears on queue
T2: T2 reads message and successfully completes


C. The message-driven bean does not perform an insert, the application performs an insert.

VALID:
T1: T1 insert successfully completes, so message is put and appears on queue
T2: T2 reads message and tries to insert but fails


D. The message-driven bean performs an insert, the application does not.

INVALID
T1: T1 insert fails then T1 rolls back, so message is put and appears on queue
T2: Message will not be available to T2, so no insert will happen. Hence invalid.



The question is
"Which statement cannot be a valid outcome of this transaction"

Answer is "D"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Part 1 - JMS question from Mock Exam
 
Similar Threads
Test 484 ... LONG POST
To Nikhil Pendharkar for IBM 287
Enthuware question doubt
IBM 287 ICE TEST
long post IBM.158