Troubleshooting issues with connections with transactional resources (databases) can be done with the help of nuxeo-core-management-jtajca
.
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 being 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 for being able to poll the mbean attributes. In NUXEO_HOME/bin/nuxeo.conf
uncomment the JMX options.
You should note that the these settings open a security hole on the server and should not be left as this in production.
# 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
You've got beans in JMX that will enable you to monitore the transactions and connections used in your system. Just point your JMX browser (such as JVisualVM which is part of the JDK) to the server and look for the following beans :
org.nuxeo.ecm.core.management.jtajca:type=StorageConnectionMonitor,name=default
- org.nuxeo.ecm.core.management.jtajca:type=DatabaseConnectionMonitor,name=NuxeoDS
org.nuxeo.ecm.core.management.jtajca:type=TransactionMonitor,name=jdoe
The connection monitoring provides you with a way to configure the pool connection size used by the Nuxeo storage. It also gives you access to global counters about the connection usage. It's enabled by default.
The transaction monitoring provides useful information about the transactions in progress in your application. Also it gives you global counters and information about the last committed and rollbacked transaction in the system. You should enable it by invoking the toggle
operation.