问题
Im writing an inbound resource adapter with JCA for a legacy EIS.
The EIS does not support XA transactions. The messages however form a conversation that exist of multiple messages. Each message leads to an action that will be executed by the message endpoint.
At the end of the conversation, a commit/rollback message will be received. At that moment all actions should be either committed or rolled back.
Is there any way that I can manage the lifecycle myself from within the RA?
回答1:
Apparantly I can answer my question myself.
When ResourceAdapter.start() is called, the provided BootstrapContext contains a XATerminator. This terminator exposes the lifecycle methods.
see
http://docs.oracle.com/javaee/6/api/javax/resource/spi/ResourceAdapter.html http://docs.oracle.com/javaee/6/api/javax/resource/spi/BootstrapContext.html
When ready to execute work, generate a XID, set it on the ExecutionContext and pass that execution context to the workmanager. (you probably need to implement a custom XID implementation)
see chapter 15 Transaction inflow of the jca 1.6 specification.
来源:https://stackoverflow.com/questions/28881889/how-to-control-xaresource-in-inbound-jca-resource-adapter-for-conversational-tra