I have a getStockQuote () function that will get the current stock quote for a symbol from the stock market.
My goal is that in a JTA transaction, the first call to getStockQuote () will receive a stock quote, but all subsequent calls within the same transaction will reuse the same stock quote (for example: it will not try to get a new quote). If another transaction starts or another transaction is running at the same time, I expect the other transaction to receive its own stock quote when it is called for the first time.
This is an attempt to ensure transaction consistency - so that all calculations in a transaction are based on the same stock price.
This will be similar to how you can configure JPA providers only once from the database row from the database and use the cached value to subsequently access the same database row in the transaction.
Does anyone have any tips on how this can be achieved?
source share