• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

mock question

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a sample question from a JDiscuss mock exam:

Question No: 28 (Question ID: 1940) Exceptions : Real Brainer

Consider the following code occuring in a MyBean code. It updates the database and sends a message to a queue named Q1. The message driven bean (not same as MyBean) associated with the queue requires a transaction and updates the database upon receiving a message.
Assuming that all the variables are properly defined and used, what will happen if the MDB associated with the queue Q1 rolls back the transaction but does not throw any exception?



Select 1 correct option.

  • Changes made by the bean code at line 24 will be committed.
  • Line 25 will throw an Exception
  • The message will be sent to the queue.
  • The message will be sent to the queue but the changes made to the database by the MDB will not be committed.
  • The container will resend the message to the queue.
  • Neither the message is sent nor any database changes get committed.


  • The mock exam marks the last option as correct, while I assumed it was the 1st. Unfortunately, no other explanations are given. So please clear this up for me...it's probably somtehing with the message send() and the MDB rolling back its tx that causes the client transaction to roll back, but I'm not clear what and why - my guess is that the client code and the MDB's onMessage() run in separate transactions since the MDB requires a TX and the client's TX cannot be propagated to it [the client never "sees" the bean].

    Thanks a bunch!
    [ September 09, 2005: Message edited by: Mihai Alexe ]
     
    Mihai Alexe
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hm,... it would appear that they posted an explanation - but not too clear - at least for me


    In this case, the sending of the message is a part of MyBean's transaction. Therefore, if it rollsback the transaction, the message will not be sent.
    The message will not be redelivered because it was never sent!
    The database changes will not be committed because the transaction was rolled back.



    Any comments on this?
     
    Ranch Hand
    Posts: 162
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello guys,
    The point is,
    The message to a Queue is actully not sent unless the contained transaction is committed. Since the tx in context is rollbacked, the actual sending of message to a queue never takes place.

    I hope there is no doubt as to the fact that db is not updated...simply coz tx is rollbacked.
    Amol
     
    If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic