Java / Java Transactions (JTA)
1. Describe Java Transaction API (JTA).
Java Transaction API (JTA) specifies standard Java interfaces between a transaction manager and the parties involved in a distributed transaction system: the resource manager, the application server, and the transactional applications. The JTA allows applications to perform distributed transactio...
2. Define transaction demarcation.
Transaction demarcation always wraps a sequence of actions, such as a single request, a single method, or a section of code within a method. The demarcation initializes some transactional behavior before the demarcated area begins, then ends that transactional behavior when the demarcated area en...
3. What are the different types of transaction demarcation?
Declarative Demarcation: When using declarative demarcation, you specify what transaction demarcation modes should be used around certain areas of code. Rather than implementing these demarcations directly in your code, you declare the demarcations in a configuration file or deployment descriptor...
4. Explain bean-managed transaction.
When an enterprise bean defines the boundaries of the transaction it is referred as bean-managed transaction. In bean-managed transaction demarcation, the code in the session or message-driven bean explicitly marks the boundaries of the transaction. Although beans with container-managed transacti...
5. Difference between a transaction and distributed transaction.
A transaction defines a logical unit of work that either completely succeeds or produces no result at all. A distributed transaction is simply a transaction that accesses and updates data on two or more networked resources, and therefore must be coordinated among those resources.
6. Name few components involved in the distributed transaction processing (DTP).
The application, application server, transaction manager, resource adapter, and the resource manager.
7. Explain resource manager in JTA context.
The resource manager is nothing but a relational database management system (RDBMS), such as Oracle, SQL Server. The actual database management is handled by this component.
8. What is resource adapter in JTA context?
The resource adapter is the component that acts as a communications channel, or request translator, between the "outside world,", the application, and the resource manager. A JDBC driver is an example of resource adapter.
9. Explain the transactional attribute Required in JTA.
Required is the default transaction attribute that ensures the methods are invoked within Java Transaction API transaction context. Required makes the transactional context used by the bean. If not the new context will be created.
10. Explain the transactional attribute RequiredNew in JTA.
RequiredNew is used when the required results of the transactions to be committed irrespective of the caller's transactions.
11. Explain the transactional attribute Mandatory.
Use the Mandatory attribute if the enterprise bean?s method must use the transaction of the client. 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 ...
12. What are the different transactional attributes?
Required, RequiresNew, Mandatory, NotSupported, Supports, and Never.
13. What is Java Transaction Service (JTS)?
JTS is a specification for implementing a Java transaction manager. A transaction manager serves as an intermediary between an application and one or more transaction-capable resource managers such as database servers and messaging systems. The JTS specification encompasses the JTA API specificat...
14. What is X/Open XA architecture?
In the X/Open XA architecture, a transaction manager or transaction processing monitor (TP monitor) coordinates the transactions across multiple resources such as databases and message queues. Each resource has its own resource manager. The resource manager typically has its own API for manipulat...
15. What is @Transactional annotation?
The javax.transaction.Transactional annotation provides the application the ability to control transaction boundaries declaratively. This annotation can be applied to any class that the Java EE specification defines as a managed bean (which includes CDI managed beans).
16. Does the J2EE platform support nested transactions?
No, the J2EE platform supports only flat transactions.
17. Should I put a transactional attribute on an asynchronous action such as sending an email?
No. Simply putting a transactional attribute on a method won't help if the resource manager can't use a transactional context.
18. Can an entity bean use bean-managed transaction demarcation?
No. Entity beans always use container-managed transaction demarcation. Session beans can use either container-managed or bean-managed transaction demarcation, but not at the same time.
19. Difference between Global transaction and local transaction.
Global Transaction is an application server managed transaction, allowing to work with different transactional resources (for example, two differences databases, database, and message queue, etc). Local Transaction is resource specific transaction (for example, Oracle DB Transactions) and applica...
20. Are JTA global transactions?
Yes.
21. What is XA transaction?
XA is a two-phase commit protocol that is natively supported by many databases and transaction monitors. It ensures data integrity by coordinating single transactions accessing multiple relational databases. XA guarantees that transactional updates are committed in all of the participating databa...