views:

450

answers:

1

In JBoss documentation there is possibility to declare <no-tx-datasource> which states:

no-tx-datasource : This element is used to specify the (org.jboss.resource.connectionmanager) NoTxConnectionManager service configuration. NoTxConnectionManager is a JCA connection manager with no transaction support.

I'm curious what can be connected by that kind of datasource? Ldap? What are practical use cases or opensource examples of this kind of configuration?

+1  A: 

Accessing to a read-only database is the most basic use case I can think about. Another one would be an application that manages the transaction state itself. And another if you want to use a connection that won't participate in a global JTA transaction. The last one happens in Quartz (see the JobStoreCMT).

But, while googling (this is a good question!), I found some more inspiration in the section Using Non-Transactional Connections of Sun's application server documentation:

The main advantage of using non-transactional connections is that the overhead incurred in enlisting and delisting connections in transaction contexts is avoided. However, use such connections carefully. For example, if a non-transactional connection is used to query the database while a transaction is in progress that modifies the database, the query retrieves the unmodified data in the database. This is because the in-progress transaction hasn’t committed. For another example, if a non-transactional connection modifies the database and a transaction that is running simultaneously rolls back, the changes made by the non-transactional connection are not rolled back.

Here is a typical use case for a non-transactional connection: a component that is updating a database in a transaction context spanning over several iterations of a loop can refresh cached data by using a non-transactional connection to read data before the transaction commits.

Interesting...

Pascal Thivent
+1 Thanks Pascal. I've google too but didn't find exhaustive informations. JDBC connection parameters suggested that can be used with databases but I didn't see purpose of that until your great explanation.
cetnar