Troubleshooting issues with connections with transactional resources (databases) can be done with the help of the built-in nuxeo-core-management-jtajca
component.
Logging Transactional Events
Configure log4j in $NUXEO_HOME/lib/log4j.xml
by adding the following keywords to your appender conversion pattern %t
for the thread name and %X
for the logging context map:
<param name="ConversionPattern" value="%d{ISO8601} %t %-5p [%c] %m %X%n" />
You should also add a new category if you want the traces to be enabled:
<category name="org.nuxeo.ecm.core.management.jtajca">
<priority value="TRACE" />
</category>
At this stage, once a transaction is started or a connection is opened, their identifiers are put in a context map for the logger. By adding the %X
keyword, you've requested to print them each a message is logged. The transactions and connections will also be logged. You should add additional log statements at level DEBUG
or TRACE
around the code you want to monitor.
Monitoring Transactional Resources
You should enable JMX to be able to poll the mbean attributes. To do this, in $NUXEO_HOME/bin/nuxeo.conf
uncomment the JMX options as follows.
You should note that the these settings open a security hole on the server and should not be left as this in production, because they allow anyone to connect to the JMX server (unless additional firewall rules have been configured).
# Enable JMX
JAVA_OPTS=$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1089 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
The Nuxeo Platform contains JMX beans that will enable you to monitor the transactions and connections used in your system. Just point your JMX browser (such as JVisualVM using the VisualVM-MBeans Plugin which is part of the JDK) to the server and look for the following beans:
org.nuxeo.ecm.core.management.jtajca:type=ConnectionPoolMonitor,name=jdbc/nuxeo
org.nuxeo.ecm.core.management.jtajca:type=ConnectionPoolMonitor,name=repository/default
org.nuxeo.ecm.core.management.jtajca:type=CoreSessionMonitor,name=default
org.nuxeo.ecm.core.management.jtajca:type=TransactionMonitor,name=default
The ConnectionPoolMonitor
provides you with a way to configure the pools connection size used by the Nuxeo storage (jdbc/nuxeo
for the JDBC datasource pool, and repository/default
for the VCS session pool). It also gives you access to global counters about the connection usage. It's enabled by default.
The TransactionMonitor
provides useful information about the transactions in progress in your application. Also it gives you global counters and information about the last committed and rolled back transaction in the system. You should enable it by invoking the toggle
operation.