nerdexam
Oracle

1Z0-895 · Question #4

A developer implements a system in which transfers of goods are monitored. Each transfer needs a unique ID for tracking purposes. The unique ID is generated by an existing system which is also used…

The correct answer is D. 0.addTransferNOT_SUPPORTED. Step 2: Must start a new transaction. use REQUIRES_NEW Step 3: No need for this step: use Use the NotSupported attribute for methods that don't need transactions. Because transactions involve overhead, this attribute may improve performance. Step 4: Use Mandatory: Use the…

Performance Tuning

Question

A developer implements a system in which transfers of goods are monitored. Each transfer needs a unique ID for tracking purposes. 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: These methods are called by the addTransfer method of a second CMT session bean in the following order: checkGooods, getUniqueId, checkAmount, storeTranfer Assuming no other transaction-related metadata, which is the correct set of transaction attributes for the methods in the session beans?

Exhibit

1Z0-895 question #4 exhibit

Options

  • A0.addTransferREQUIRED
  • B0.addTransferREQUIRED
  • C0.addTransferREQUIRED
  • D0.addTransferNOT_SUPPORTED

How the community answered

(19 responses)
  • A
    5% (1)
  • B
    16% (3)
  • C
    5% (1)
  • D
    74% (14)

Explanation

Step 2: Must start a new transaction. use REQUIRES_NEW Step 3: No need for this step: use Use the NotSupported attribute for methods that don't need transactions. Because transactions involve overhead, this attribute may improve performance. Step 4: Use Mandatory: Use the Mandatory attribute if the enterprise bean's method must use the transaction of the client. *In an enterprise bean with container-managed transaction(CMT)demarcation, the EJB container sets the boundaries of the transactions. You can use container-managed transactions with any type of enterprise bean: session, or message-driven. Container-managed transactions simplify development because the enterprise bean code does not explicitly mark the transaction's boundaries. The code does not include statements that begin and end the transaction. *A transaction attribute can have one of the following values: *Required Attribute If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container starts a new transaction before running the method. The Required attribute is the implicit transaction attribute for all enterprise bean methods running with container-managed transaction demarcation. You typically do not set the Required attribute unless you need to override another transaction attribute. Because transaction attributes are declarative, you can easily change them later. *RequiresNew Attribute If the client is running within a transaction and invokes the enterprise bean's method, the container takes the following steps: Suspends the client's transaction Starts a new transaction Delegates the call to the method Resumes the client's transaction after the method completes If the client is not associated with a transaction, the container starts a new transaction before running the method. You should use the RequiresNew attribute when you want to ensure that the method always runs within a new transaction. *Mandatory Attribute If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container throws the TransactionRequiredException. Use the Mandatory attribute if the enterprise bean's method must use the transaction of the client. *NotSupported Attribute If the client is running within a transaction and invokes the enterprise bean's method, the container suspends the client's transaction before invoking the method. After the method has completed, the container resumes the client's transaction. If the client is not associated with a transaction, the container does not start a new transaction before running the method. Use the NotSupported attribute for methods that don't need transactions. Because transactions involve overhead, this attribute may improve performance. The Java EE 5 Tutorial,Container-Managed Transactions

Topics

#CMT#REQUIRES_NEW#transaction demarcation#NOT_SUPPORTED

Community Discussion

No community discussion yet for this question.

Full 1Z0-895 Practice