• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Part 1 - JMS question from Mock Exam

 
A.G. Arun
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11852
185
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
A.G. Arun
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Amol. Your explanation helps.

Question source: practice exam from Sun - link
 
Gladwin Burboz
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic