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 6365641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:19:06+00:00 2026-05-25T00:19:06+00:00

We utilize in-memory LRU caches for several different models across our application. To avoid

  • 0

We utilize in-memory LRU caches for several different models across our application. To avoid issues arising from transactions being rolled back (like stale entries), a notion of transactional caches was added: A temporary cache is created for each transaction, and then entries are discarded if it gets rolled back or they are copied over to the main cache for that model if it’s committed.

To accomplish this, the cache implements XAResource and overrides the commit() and rollback() methods. Whenever a new Transaction wants to access some data that’s not in the main cache, a transactional cache is created and passed into enlistResource().

The problem is that I was trying to call delistResource() on the cache instance within the commit() and rollback() methods, which was throwing an IllegalStateException, saying the transaction was already marked for rollback (or commit). So I was wondering… is it okay to not delist the cache as a resource (in other words, it already gets delisted as part of the rollback or commit process), or is there another point in the flow where it should be called?

  • 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-25T00:19:07+00:00Added an answer on May 25, 2026 at 12:19 am

    It’s not the XAResource’s methods that call delistResource, it’s the app server’s Transaction implementation. If you want a resource to be delisted, obtain the transaction and call delist on that, it will call end() on the resource for you as needed. The transaction manager likewise calls end() implicitly as part of the termination processing, so you don’t do so manually at commit or rollback. The only case in which you need to handle a delist is when using the same resource instance in multiple transaction contexts. For example

    
        Cache c = getCache();
        c.makeUpdate(); // no transaction running, should auto commit.
        tx.begin(); // start tx A
        c.makeUpdate(); // transactional within A
        tx.suspend();
        tx.begin(); // start tx B
        c.makeUpdate(); // transactional within B
        tx.commit(); //end B
        tx.resume(A);
        tx.commit(); // end A
    
    

    Depending on your cache implementation you may need to delist on suspend and enlist again on resume, but not for commit or rollback. Alternatively you check the transaction context on each makeUpdate() call rather than relying on the sequence of enlist/delist calls to update the effective tx context held by the resource instance.

    This stuff is hard, due to the poor mapping between the procedural XA spec and the more or less Object Oriented JTA spec. Frankly you are probably better off leaving it to the experts. JBoss Infinispan for example provides an open source transactional cache that takes care of all this for you and offers plenty of other features besides.

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

Sidebar

Related Questions

We have a requirement to have a In Memory copy of data from our
I’m trying to utilize the .NET Framework 3.5 Client Profile in my application but
I have an application that sometimes will utilize a large amount of data. The
Related to my previous question: Preventing Memory issues when handling large amounts of text
In my application,I have to load volumedata from set of images (MRC images) and
what is the limit of memory that printf can utilize for storing its computed
I want to read from one file that has several kinds of data-types. I
Is there any limit on the physical memory size (file system) one can utilize
I'm looking to implement some templates in a web application and wanted to utilize
I'd like to utilize an ICE Faces fileInput control to fill in the file

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.