11. Audit
File auditor
First install the audit feature:
smx@root:/> features/install nmr-audit
Then create a file named deploy/servicemix-file-audit.xml
with the following content:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" /> <bean id="file-auditor" class="org.apache.servicemix.nmr.audit.file.FileAuditor"> <property name="directory" value="${servicemix.base}/data/audit/file" /> </bean> <osgi:service ref="file-auditor"> <osgi:interfaces> <value>org.apache.servicemix.nmr.api.event.Listener</value> <value>org.apache.servicemix.nmr.api.event.ExchangeListener</value> </osgi:interfaces> </osgi:service> </beans>
Here you go, all exchanges will be logged into the data/audit/file
directory.
JDBC auditor
First install the audit feature:
smx@root:/> features/install nmr-audit
Then, install the required database (we use HSQLDB here). As there is no OSGi bundle for this database, we use the wrap
url handler to create one on the fly.
smx@root:/> osgi/install -s wrap:mvn:hsqldb/hsqldb/1.8.0.7
Then create a file named deploy/servicemix-jdbc-audit.xml
with the following content. This example uses the HSQLDB database, but you can configure any DataSource.
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" /> <bean id="jdbc-auditor" class="org.apache.servicemix.nmr.audit.jdbc.JdbcAuditor"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="dataSource" class="org.hsqldb.jdbc.jdbcDataSource"> <property name="database" value="jdbc:hsqldb:file:${servicemix.base}/data/audit/jdbc/hsqldb" /> <property name="user" value="sa" /> </bean> <osgi:service ref="jdbc-auditor"> <osgi:interfaces> <value>org.apache.servicemix.nmr.api.event.Listener</value> <value>org.apache.servicemix.nmr.api.event.ExchangeListener</value> </osgi:interfaces> </osgi:service> </beans>
Commands
A few commands are available to access the audited exchnanges:
audit/count audit/ids audit/exchanges audit/delete