Question

Using Ejb3.0, Weblogic 11g, JDBC

I am invoking a method which is running remotely in another deployment EAR.

The method in the remote deployment being invoked but it's annotated with the @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

the problem is that all the logic I do in the database before the remote method is being invoked wont commit till the remote method finished.

What I willing to do is a commit to let the "before" logic take place" and when I get back after the remote call to continue normally.

Any idea?

Some code to explain:

@CallByReference
@Stateless(mappedName = "ejb/OperatorProccessBean")
@Local({ OperatorProccessBeanLocal.class })
@Remote({ OperatorProccessBeanRemote.class })
public class OperatorProccessBean implements OperatorProccessBeanLocal,  
 OperatorProccessBeanRemote
{   

...

   SBNDispatchBeanRemote SBNDispatchBean = (SBNDispatchBeanRemote) context.lookup("ejb/SBNDispatchBean#com.mirs.sbn.dispatch.SBNDispatchBeanRemote");
    if (SBNDispatchBean == null)
    {
            logger.error(TAG + " SBNDispatchBean is null");

    }
    else
    {
         //until here I want all my data to be commited without waiting for the upcoming remote method to finish
         SBNDispatchBean.updateSubscriberInBlockingList(...);
    }
...
 }

Now the method updateSubscriberInBlockingList() is annotated with

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

i want the data to be commited before that method being invoked.

Thanks in advance, ray.

Was it helpful?

Solution

Now the method updateSubscriberInBlockingList() is annotated with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

I want the data to be commited before that method being invoked.

Given that you are using container managed transactions, it is not possible. The rationale behind this, is that when the container is already performing a transaction, then starting a new transaction will result in the original being suspended. When the new transaction has committed, the original transaction will be resumed.

This behavior is not configurable, for the EJB container and the JTA Transaction Manager is expected adhere to the behavior specified in the JTA specification, which is derived from X/Open DTP transaction model. In the X/Open DTP model, if there is a new transaction is started, while another is in progress, the current one is suspended, and resumed at a later point in time. It should be noted that no transaction model, would possibly (I haven't studied all) allow for committing the current transaction and starting a new one. I have only seen nested transactions or suspended transactions being supported in the various transaction processing models.

If you want to have the work committed, you must have the existing transaction context terminated completely, so that the existing transaction will commit, and then start the new transaction.

OTHER TIPS

Put the "before remote call" logic in a separate bean method annotated with REQUIRES_NEW as well. You will thus have three transactions :

  • one for the main method (but which won't do anything until th remote call is done);
  • one for the logic before the remote call;
  • one for the remote call.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top