-
1. Re: Narayana and Spring with multiple JVM
tomjenkinson Feb 27, 2014 2:53 AM (in response to dineshjweerakkody)Hi Dinesh,
Thanks for your interest in Narayana!
I understand your scenario and what I would say is that moving to remote EJB invocations inside WildFly AS is probably going to be easiest for you. You certainly can run JTS in standalone mode and we do have a documentation set for this on narayana.io. We also have a quickstart that can be used standalone: https://github.com/jbosstm/quickstart/tree/master/ArjunaJTS/trailmap . Now, I haven't looked through that QS for years but it should still apply. If you were in a position to use WildFly I can recommend using this quickstart instead: https://github.com/jboss-developer/jboss-eap-quickstarts/tree/6.3.x-develop/jts
Take a look at them both and have a think of which application you would prefer to build.
Hope it helps,
Tom
-
2. Re: Narayana and Spring with multiple JVM
dineshjweerakkody Feb 27, 2014 4:06 AM (in response to tomjenkinson)Dear Tom,
Thank you very much for your quick reply. We can use WildFly AS but will not be able to use EJB because we have finished most of the development using Hibernate. Anyway I'll go through the documents and get back to you soon.
Thanks again..
-
3. Re: Re: Narayana and Spring with multiple JVM
tomjenkinson Feb 27, 2014 4:18 AM (in response to dineshjweerakkody)No problem.
I would add a small EJB between the existing app and existing clients to propagate the transport.
Whatever approach you take you will need to write some more code, I suspect the EJB code would be smaller in comparison to the alternative but I may be wrong.
There are alternative methods of propagating the transaction, we have a webservices transport and a REST one. Let me know if you think these might help. There should be quickstarts for these in https://github.com/jbosstm/quickstart/
Tom
-
4. Re: Narayana and Spring with multiple JVM
damiano.pezzotti Jun 10, 2014 6:57 AM (in response to tomjenkinson)Hi Tom,
Do you have an example on transaction propagation using REST?
We have a similar problem. 2 applications on different war files that communicate via hessian protocol (based on HTTP, then very similar to REST) and we are trying to create a global transaction across the 2 applications.
Thanks
Damiano
-
5. Re: Narayana and Spring with multiple JVM
tomjenkinson Jun 10, 2014 7:06 AM (in response to damiano.pezzotti)Hi Damiano,
You could take a look at our RTS quickstarts over here: https://github.com/jbosstm/quickstart/tree/master/rts
Tom
-
6. Re: Narayana and Spring with multiple JVM
damiano.pezzotti Jun 10, 2014 9:06 AM (in response to tomjenkinson)Hi Tom,
thanks for your response.
I'm not sure that your link solves my problem, then I try to describe it with more details.
We have 2 applications packaged as war running on JBoss 7.1.1.
These applications uses Spring and JPA and communicate each other using Spring Remoting (using Hessian Protocol).
The first application start the transaction and writes data on db1.
Then it calls a service exposed via Hessian protocol by the second application. This service writes data on db2 and then returns control to the first application.
The first application writes data on db1.
If this operation fails, I want to rollback the entire transaction.
Is it possible to using JBossTM for this scenario?
-
7. Re: Narayana and Spring with multiple JVM
tomjenkinson Jun 10, 2014 10:43 AM (in response to damiano.pezzotti)Hi Damiano,
Ah, I thought you were asking after REST examples. We don't have a hessian transport for JBossTM out of the box. Is there a transaction API for hessian do you know? The core of JBossTM is a pluggable architecture and we have support for many transports: JTS/SOAP/REST/JBoss Remoting. If there is some way to integrate hessian with REST stuff it might work.
Tom
-
8. Re: Narayana and Spring with multiple JVM
damiano.pezzotti Jun 10, 2014 11:00 AM (in response to tomjenkinson)Hi Tom,
Unfortunately hessian doesn't support transactions out-of-the-box, but we'd like to try to implement the mechanism (hessian is based on HTTP).
The idea is to start the transaction on the first application and then propagate it using the remote hessian call.
If application one or application two has an error, the entire transaction is rolled back.
Do you think it is possible? If yes, how can I propagate the transaction? Is it possible to pass a sort of transactionId using an HTTP header?
Thanks
Damiano
-
9. Re: Narayana and Spring with multiple JVM
tomjenkinson Jun 10, 2014 11:09 AM (in response to damiano.pezzotti)Hi Damiano,
It should certainly be possible but its not supported out of the box and would required you to write the transport adaptors. One of the best examples of this would probably be the way that the JBoss Remoting transport was written. You could take that as a template. They basically register as an XAResource and then serialize and ship the Xids around and respond to the transaction managers XAResource invocations. Special consideration is required at recovery.
You can see the way they integrate with the recovery manager here (look at the recover() method: https://github.com/jbossas/jboss-ejb-client/blob/master/src/main/java/org/jboss/ejb/client/RecoveryOnlyEJBXAResource.java)
You could also use RTS as a start point, but if you have XA calls already it might be easiest to just sit behind the XAResource interface.
Hope it helps,
Tom
-
10. Re: Narayana and Spring with multiple JVM
damiano.pezzotti Jun 10, 2014 12:00 PM (in response to tomjenkinson)Hi Tom,
Thanks for your support.
I think that JBoss Remoting could be a similar scenario for me.
Where can I find code for remoting/jbosstm integration?
Regards
Damiano
-
11. Re: Narayana and Spring with multiple JVM
tomjenkinson Jun 11, 2014 7:00 AM (in response to damiano.pezzotti)Hi Damiano,
It's in that repo I linked to above. Clone the repo and look for the XAResource implementations, iirc there are two, one for recovery and one for normal usage. Once you have found the XAR it should be relatively straightforward to see how the propagation is done for JBoss Remoting. The next thing is to see how the XAR are registered with the transaction manager. The recovery one is straight forward, the one that is registered when the transaction propagates is a bit more complex and would be the toughest bit for you to implement I suspect. With your application you will need to register a hook that anytime it propagates to another server you need to hook in an XAResource if its not already enlist for that TX at that server pair.
Tom