Discussions

EJB design: Using uer transaction JTS in ejb

  1. Using uer transaction JTS in ejb (5 messages)

    Using uer transaction in ejb We are currently migrating an old application which is in production since 5 years. This application has several session beans with bean managed transactions.In the process of migration we are adding new features . We created new beans with container managed transaction. For example A Struts action class Has a delegate call resendMsg = ObligationTransactionDetailsDelegate.resendObligation(actionId, comments, entryUser); to add the new feature I added call to new delegate AmendmentsDelegate.updateNewWorkflow(entryUser, amendmentId, reviewStatus,taskAlias); Because of the two delegates the action class is not in one transaction. Also I cannot update the method ObligationTransactionDetailsDelegate.resendObligation to call AmendmentsDelegate.updateNewWorkflow because the old bean has bean managed transaction and the new bean is container managed. My question is is there any way I can club them into one transaction without changing any code like using javax.UserTransactions or something.

    Threaded Messages (5)

  2. Re: Using uer transaction JTS in ejb[ Go to top ]

    Hi Yes it should work with the standard transaction managment that the container should provide. Please try writing a client like this: Properties prop = new Properties(); prop.load(new FileInputStream("jndi.xml")); //init context InitialContext ctx = new InitialContext(prop); // obtain transaction. The KEY "UserTransaction" is valid on jboss server UserTransaction tx = (UserTransaction)ctx.lookup("UserTransaction"); tx.begin(); // do the work with your delegates // here rollback so you can check if both beans are under the same transaction tx.rollback(); // do not forget!!! ctx.close(); Good luck.
  3. Re: Using uer transaction JTS in ejb[ Go to top ]

    Sorry I have made a mistake (did not understand the question), I'm afraid that there is no possibility to bind those transactions using containers transaction manager.
  4. Whats the transaction attribute? I meant to know flags like (Supports, Required, Requires New, Mandatory .. etc) Imagine that both the beans have either "Supports" or "Required", then this is what you can try:- 1. Write a Facade bean with bean-managed-transaction and attribute either of Supports/Required/Requires-New 2. Call Obligation bean (which is BMT). 3. Call Amend bean (which as CMT) 4. Commit or Rollback the transaction. Assumption is that since Obligation and Amend bean have "Required" or "Supports" flag, they will live within Facade bean transaction umbrella. Another reason why this seems logical is transaction manager of respective beans (either Bean or Container) simply indicates "Who" will manage the transaction processing but here Facade bean will decide "When-To-Do" and "What-To-Do". Hence when facade triggers the COMMIT on both the beans their respective TMs should implement the commit process and same thing for Rollback. Please give a try on this
  5. I am curious to know if above solution works or does not work. PLease reply your feedback. Cheers, shrini
  6. The above solution should work even with Mandatory as attribute. cheers shrini