| Author |
How to control the transaction with external system?
|
Larr Goneg
Greenhorn
Joined: Jul 02, 2003
Posts: 23
|
|
Normally if you use CMT to manage transaction in EJB, the container will take care of all the commit and rollback job(which is the same as commit of rollback in Database, I think), but what if the EJB's change is not a database update? For example, a EJB PaymentEJB access external creditcard service using special protocol, I'd like following in one transaction, payCreditCard(){ accessExternalservice(); xxxx(); } in this case, how to control the transaction? Do I have to write something like commit and rollback myself in accessExternalservice()? Thanks.
|
 |
Larr Goneg
Greenhorn
Joined: Jul 02, 2003
Posts: 23
|
|
Ok, I found this post is helpful http://www.coderanch.com/t/151338/java-Architect-SCEA/certification/Transactions-guarantee but still didn't get a clear understanding! Some one kind enough to show some light for me? according to BluePrint As of version 1.3 of the J2EE platform, a J2EE product is required to support access within a single transaction to: • A single JDBC database (multiple connections to the same database are allowed) • A single Java Message Service (JMS) provider, and • Multiple Enterprise Information Systems (EISs) through resource adapters (Connectors) specifying the XATransaction transaction level Access to multiple JDBC databases within a single transaction is not required But in case of 1. I want to have a unit-of-work, which should be executed in one transaction, but there are data update from different Database. 2. If in the transaction, I also want to include a transaction with external system through http protocol. What should I do to make it participating the whole transaction? Do I need to write the ResourceManager to support XATransaction from the ground? Thank you very much if you can show some light!
|
 |
Juan Rolando Prieur-Reza
Ranch Hand
Joined: Jun 20, 2003
Posts: 233
|
|
I agree with Andrew Perepelytsya's analysis (May23). I think the point that you might have been looking to clarify is this: Within your (J2EE) Transaction, you will make some kind of synchronous call to an external system, which in turn probably performs its own transaction. Your "J2EE" application's Transaction does not need to have any awareness that some other transaction was being performed. To you, its just some atomic operation that either succeeds or fails. Failure = either it returns some "failure" or refusal message, or it throws an unpleasant exception. Because of this atomicity requirement, your call to the external system must be synchronous (not via async messaging, say). So, my take is that the EJB spec's "silence" on the point about nesting transactions is just fine as is.
|
Juan Rolando Prieur-Reza, M.S., LSSBB, SCEA, SCBCD, SCWCD, SCJP/1.6, IBM OOAD, SCSA
|
 |
Pamir Bahret
Greenhorn
Joined: Jul 17, 2003
Posts: 21
|
|
But if you have two not transactional calls, let say one for payment system and one for mileage system? How you deal with that case? Is compensating transactions useful? In your example I think the last operation in the path of payment must be the access to not transactional service because if method xxxx() fail how you deal with rollback? [ August 11, 2003: Message edited by: Pamir Bahret ]
|
 |
 |
|
|
subject: How to control the transaction with external system?
|
|
|