Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3957084
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:26:46+00:00 2026-05-20T02:26:46+00:00

Because the TransactionManager has no way to register a XAResource manager, so that it

  • 0

Because the TransactionManager has no way to register a XAResource manager, so that it can enlist XAResources in future Transactions.

The only way to solve this problem is to wrap the handle of the interested service interface.
Each method on the interface does the following:

  • Check if a tx is present
  • Figure out if the handle for this tx
  • If not already participating enlist its XAResource using Transaction.enlist(XAResource)
  • Registers a callback to enable cleanup using Transaction.registerSynchronization(Synchronization).

Does this seem like a reasonable strategy ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:26:47+00:00Added an answer on May 20, 2026 at 2:26 am

    It’s a reasonable first draft, but there are some subtleties to watch out for. Getting the corner cases right yourself is hard – you may be better off writing a resource adaptor for your code and having a JCA handle the transaction plumbing, which is what most database and message queue drivers do.

    • Just because a tx context is present, that does not mean you can enlist with the tx. In particular the spec requires enlistResource to throw RollbackException if the tx is marked rollback only.

    • Just because the context is present and the tx has a valid state at the time you check it, that does not mean it remains present or valid throughout the lifetime of the method call. You can get race conditions in which the TM calls rollback on the resource whilst your business logic is still running.

    • The relationship between XAResource object instances, instances of the service interface and transactions is not particularly elegant due to XA’s C heritage. In connection oriented APIs like JDBC it is normally one XAResource per Connection, with that XAResource instance potentially managing multiple tx contexts. For connectionless APIs you can use other patterns which may be simpler.

    • The Synchronization is not necessary. Nor is it necessarily desirable as Synchronizations are volatile so your cleanup won’t get called in crash recovery situations. Better to clean up on commit/rollback in non-heuristic cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Because I'm lazy I was wondering if PHP has a shorthand way to set
Because of the way that our git repos are setup I have some static
Because regular expressions scare me, I'm trying to find a way to remove all
Because of the more tedious way of adding hosts to be monitored in Nagios
Because I am a newbie I am trying to log out any errors that
Because I've made .cpp files and then transferred them into .h files, the only
Because this is my first attempt at an extension method that seems quite useful
Because of the way in which YES/NO are defined, you cannot use YES/NO with
Because anyone can sign up and then log in,... and because a user isn't
Because of an imminent deadline, I'm looking for the easiest viable way to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.