I would not try to mimic 2PC as it will never work with the same reliability.
Instead I would go for LocalTransaction.
WebSphere has a feature called Last Participant Support that allows to add one 1PC resource into a transaction with multiple 2PC resources, committing the 1PC resource after prepare and committing the other resources if the commit to the 1PC resource succeeds and rolls back otherwise.
I bet that JBoss has something similar. ;-)
Yeah, this confirms my feelings on the matter. JBoss equivalent is LRCO I'm gonna opt for an underlying DB which supports a "prepare" phase.
I appreciate that you have now moved on, and don't need this anymore. However, I'll reply anyway, so that others in your position can benefit and incase you change your mind...
You have two options:
1. LRCO (as you and Robert suggest). This is quite simple for you to implement, but does have a failure window which can leave the transaction in an inconsistent state. This happens if a failure occurs after the TM informs the one phase resource to commit, but before it hears back if it was successful. In this case the TM can't find out what happened to the one phase resource during recovery.
2. Commit Marker Resource (CMR). This is a new Narayana feature that allows a single 1 phase resource to be enlisted in the transaction and doesn't exhibit any failure windows. The crux of the protocol is that some transaction data is committed in the same local transaction as the business logic's update to the one-phase resource. The TM can look for this data at recovery time to see if the local transaction committed or not. The down-side is that it's harder for you to implement than LRCO. I'm not sure that CMR is documented yet, as it's a very new feature. tomkins: is it documented yet?