The following are examples of using J2EE connectors between EJBs and Enterprise Server in both transactional and non-transactional
scenarios:
- Scenario 1: Non-transactional
-
EJB Communication
|
Stateless
|
Enterprise Server Communication
|
Stateless
|
- Use
- Invoke a COBOL procedure where there is no state to be maintained for the EJB or the SEP between it and the next COBOL procedure
invocation.
- Example
- getInvoiceDetails(String
invoiceNumber) returns just the invoice details for the specified string. Multiple calls to this procedure do not require state.
- Implementation
- During EJB generation from the IMTK, use JNDI to get an EJB based on the service interface name. Internally this calls the
Resource Adapter, which then calls COBOL.
- Scenario 2: Non-transactional
-
EJB Communication
|
Stateful
|
Enterprise Server Communication
|
Stateful
|
- Use
- Invoke one or more COBOL procedures where the state must be maintained in the EJB and the SEP, meaning that each invocation
accessed the same SEP. You can also convert a non-transactional stateful invocation into a stateless invocation by storing
the state for each invocation in a database rather than in the program. The application design dictates whether or not it
is necessary to maintain the state in the program or if it can also be maintained in a database.
- Example
- When you add an item to a shopping cart, it places the item into the cart with other items placed there previously. When you
purchase all items in the shopping cart, this completes the sale. In this scenario, you can keep all items in the shopping
cart in working storage and use it across multiple invocations.
- Implementation
- Invoke a COBOL procedure where there is no state to be maintained for the EJB or the SEP between it and the next COBOL procedure
invocation. However, after using the stateful bean, the end user must invoke a remove procedure to dispose of the transient
SEP created exclusively to interact with the EJB, and remove the stateful EJB from the container.
- Scenario 3: Transactional
-
EJB Communication
|
Stateful
|
Enterprise Server Communication
|
Stateless
|
- Use
- Use this scenario when you want transactional interaction without extending the SEP life beyond the xa_commit/xa_rollback.
The SEP is automatically disposed of after xa_commit/xa_rollback.
- Implementation
- Remove the EJB for every transaction and create a new one for the next transaction.
- Scenario 4: Transactional
-
EJB Communication
|
Stateful
|
Enterprise Server Communication
|
Stateful
|
- Use
- Use this scenario when you want transactional interaction that keeps the SEP life beyond the xa_commit/xa_rollback.
- Implementation
- Remove the EJB after all work is completed.