How can i attach data to a JTA transaction? (or uniquely identify it)

Posted by kwyjibo on Stack Overflow See other posts from Stack Overflow or by kwyjibo
Published on 2010-05-17T22:28:21Z Indexed on 2010/05/17 22:30 UTC
Read the original article Hit count: 203

Filed under:
|
|

I have a getStockQuote() function that will get a current stock quote for a symbol from the stock market.

My goal is that within a JTA transaction, the first call to getStockQuote() will fetch a stock quote, but all subsequent calls within the same transaction will reuse the same stock quote (e.g.: it will not try to fetch a new quote). If a different transaction starts, or another transaction runs concurrently, i would expect the other transaction to fetch its own stock quote on its first call.

This would be similar to how you can configure JPA providers to only fetch a database row from the database once, and use the cached value for subsequent access to the same database row within the transaction.

Does anyone have tips on how this can be achieved?

© Stack Overflow or respective owner

Related posts about java

Related posts about jta