Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

My exam cloud, mock 3, transaction for the addTransfer method and etc

 
Bartender
Posts: 2124
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


...Each transfer needs a unique ID for tracking purpose. The unique ID is generated by an existing system which is also
used by other applications. For performance reasons, the transaction that gets the unique ID should be as short as possible.
The scenario is implemented in four steps which are implemented in four business methods in a CMT session bean:
1. checkGoods - Checks goods in a database
2. getUniqeId - Retrieve the unique ID
3. checkAmount -Checks  the amount in a non-transactional system
4. storeTransfer - Stores the transfer in a database as part of the calling transaction.

These methods are called by the addTransfer method of a second CMT session bean in the following order:
checkGoods, getUniqueId, checkAmount, storeTransfer
Assuming no other transaction-related metadata, which is the correct set of transaction, attributes for the methods in the session
beans?
A.
0.addTransfer - Required
1.checkGoods  - Required
2.getUniqueId - Required_New
3.checkAmoutns - Not_Supported
4.storeTransfer - Mandatory

B.
0.addTransfer - Required
1.checkGoods  - Required
2.getUniqueId -Required
3.checkAmoutns - required
4. storeTransfer  - required

C
0.addTransfer - required
1.checkGoods  - Required
2.getUniqueId - Required_New
3.checkAmount - Never
4.storeTransfer - Mandatory

D.
0.addTransfer - Not_Supported
1. checkGoods - Required
2. getUniqueId - Required
3. checkAmounts -Not_Supported
4. storeTransfer - Mandatory

Answer A.

Explanation:
The unique  ID is generated by an existing system which is also used by other applications. For performance reasons,
the transaction that gets the unique ID should be as short as possible.
So, we should use REQUIRES_NEW finish the method as short as possible.



The question specified that getUniqueId should be done as soon as possible for higher performance. But the suggested solution is to use REQUIRES_NEW for getUniqueId().
When this getUniqueId is run in a new transaction, the overhead to create that new transaction is high and may affect the performance.
So, I think getUniquedId should use REQUIRED, SUPPORTS or even NOT_SUPPORTED.  If it uses REQUIRED OR SUPPORTS, it will be run in the transaction of addTransfer.
If it uses NOT_SUPPORTED, it will run in a non-transactional context.

Since getUniqueId is used for getting the id, not committing any data , it is fine to run it in a non-transactional context.
 
Creator of Enthuware JWS+ V6
Posts: 3398
312
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem statement clearly says "the transaction that gets the unique ID should be as short as possible" which means it can only be REQUIRES_NEW (is the mock realy using required_new??).
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic