One datasource, two db schemas, two nuxeo repositories

  • Nuxeo 5.8
  • Postgres 9.2

I need another repository besides the default one. Its role is to be an archive of old documents.

I have defined it as a contribution:

<repository name="documentArchive" factory="org.nuxeo.ecm.core.storage.sql.ra.PoolingRepositoryFactory">
    <repository sendInvalidationEvents="true">
        <xa-datasource>org.postgresql.xa.PGXADataSource</xa-datasource>
        <property name="ServerName">127.0.0.1</property>
        <property name="PortNumber">5432</property>
        <property name="DatabaseName">nuxeo_archive</property>
        <property name="User">nuxeo</property>
        <property name="Password">nuxeo</property>
    </repository>
</repository>

I have made the nuxeo_archive database to hold this.

What I acctualy wanted was to put this in a specific database schema in the same database as the default repository so they can share the connection. But I could not find a way to define it like this.
Is this possible?

I like the Single-Datasource Mode that comes as default for all connections and I would like to stick to it. Without this I need to fall back to XA transactions that I try to avoid.

Another aproach that I have been looking into is to use the single datasource mode with an exclusion on documentArchive and use compensation on failed transactions to documentArhive. In nuxeo.conf I have put:

nuxeo.db.singleDataSource.exclude=repository_documentArchive

but I get this exception when the default respository connection is beeing closed:

ERROR [http-bio-0.0.0.0-8080-exec-5] [org.nuxeo.ecm.core.storage.sql.jdbc.JDBCLogger] (5) SQL: XA end error on org.apache.geronimo.transaction.manager.XidImpl@76c188fa
java.lang.NullPointerException
    at org.nuxeo.ecm.core.storage.sql.jdbc.JDBCMapper.end(JDBCMapper.java:1317)
    at org.nuxeo.ecm.core.storage.sql.SoftRefCachingMapper.end(SoftRefCachingMapper.java:182)
    at org.nuxeo.ecm.core.storage.sql.SessionImpl.end(SessionImpl.java:1430)
    at org.nuxeo.ecm.core.storage.sql.ra.ConnectionAwareXAResource.end(ConnectionAwareXAResource.java:59)

Questions:

  • How should I define both repositories to use the same datasource but different database schemas so I can use non-XA datasources ?
  • Is it something wrong on how I try to use the “nuxeo.db.singleDataSource.exclude” option?
0 votes

1 answers

1248 views

ANSWER



nuxeo.db.singleDataSource.exclude has not been much tested so it's not surprising if there are bugs.

I don't think it's possible to use the same datasource but different databases. Single-datasource mode is mainly designed to share the datasource between VCS and other JDBC accesses in Nuxeo, not for do multi-database.

For the repository definition we don't have a way to specify the schema to use sorry. That would be the solution for you but it's not implemented.

0 votes



In fact, if you try to use nuxeo.db.singleDataSource.exclude in nuxeo.conf, it throws

FreeMarker templates: nuxeo.db.singleDataSource is already defined - nuxeo.db.singleDataSource.exclude will not be available in the data model.
04/20/2015