Instructions on using DataStore with concurrent J2EE transactions

Description

ContentFeatureSource is currently referencing a single transaction object, causing problems when it is accessed by multiple threads that work against different transactions (a common occurrence in J2EE environments).

I propose to add an indirection, so transactions can be cached and accessed on a thread-local basis:

public abstract class ContentFeatureSource {
public void setTransactionCache(TransactionCache transactionCache){
this.transactionCache = transactionCache;
}
}

public interface TransactionCache {
// returns a thread-local transaction
Transaction getTransaction();

}

Environment

None

Activity

Show:
codehaus
April 10, 2015, 3:33 PM

CodeHaus Comment From: jandm - Time: Thu, 14 Feb 2013 11:08:43 -0600
---------------------
Hi Jody,

regardless of the hashmap problem (which for now i consider a bug), the most sensible way to work with transactions/sessions in a web environment seems to be to make them thread-scoped, right ?

When using transaction demarcation through annotations (as in Spring), that can be achieved by configuring a custom transaction manager that - using AOP - intercepts each transactional call and creates a geotools transaction when needed. I will try this now in combination with the buildTransaction() approach and let you know.

codehaus
April 10, 2015, 3:33 PM

CodeHaus Comment From: jandm - Time: Mon, 18 Feb 2013 03:36:21 -0600
---------------------
Thread-scoped transaction works nicely when combined with map fix. I made issue <a href="https://jira.codehaus.org/browse/GEOT-4394" title="ContentEntry used in ContentDataStore is not thread-safe" class="issue-link" data-issue-key="GEOT-4394"><strike>GEOT-4394</strike></a> for the map problem.

codehaus
April 10, 2015, 3:33 PM

CodeHaus Comment From: jandm - Time: Wed, 20 Feb 2013 07:12:04 -0600
---------------------
Attached is a documentation patch. There is a link to a Geomajas class that illustrates our current approach based on TransactionSynchronization.

codehaus
April 10, 2015, 3:33 PM

CodeHaus Comment From: aaime - Time: Sat, 20 Apr 2013 05:37:00 -0500
---------------------
Thanks, patch merged on 9.x and trunk.

Andrea Aime
February 15, 2017, 11:36 AM

Mass transitioning all resolved issues that have not been updated in the last month to closed state

Assignee

Unassigned

Reporter

codehaus

Triage

None

Components

Priority

Medium
Configure