+49 228 5552576-0


info@predic8.com

Logging Service Invocation Metadata to Database

Using the StatisticsJDBCInterceptor, Membrane Monitor and Router can log metadata about service invocation to any database that can be accessed via JDBC.
Each entry in the database will contain:

To activate database logging you can use the following template for the proxies.xml file:
				<spring:beans xmlns="http://membrane-soa.org/proxies/1/"
					xmlns:spring="http://www.springframework.org/schema/beans"
					xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
					xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
									    http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd">
					
					<spring:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
						[...]
					</spring:bean>
					
					<router>
					
						<serviceProxy name="predic8.com" port="2000">
							<statisticsJDBC dataSource="dataSource" />
							<target host="membrane-soa.org" port="80" />
						</serviceProxy>
						
					</router>
					
				</spring:beans>

The configuration of the dataSource spring bean still has to be filled in.

Data Sources

If you are using MySQL:

Replace the spring:bean definition of the bean with the ID dataSource by:
<spring:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
	<spring:property name="driverClassName" value="com.mysql.jdbc.Driver" />
	<spring:property name="url" value="jdbc:mysql://localhost:3306/membrane" />
	<spring:property name="username" value="root" />
	<spring:property name="password" value="root" />
</spring:bean>
Adjust the url, username, and password properties, restart the application, and you're all set.

If you are using Oracle:

Replace the spring:bean definition of the bean with the ID dataSource by:
<spring:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
	<spring:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
	<spring:property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:your-database" />
	<spring:property name="username" value="your-username" />
	<spring:property name="password" value="your-password" />
</spring:bean>
Adjust the url, username, and password properties, restart the application, and you're all set.

Note: if you drop the 'statistic' table for some reason, do not forget to delete the sequence named 'stat_seq' and the trigger named 'stat_seq_trigger'.

If you are using Derby:

Replace the spring:bean definition of the bean with the ID dataSource by:
<spring:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
	<spring:property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
	<spring:property name="url" value="jdbc:derby://localhost:1527/membranedb-test;create=true" />
	<spring:property name="username" value="APP" />
	<spring:property name="password" value="root" />
</spring:bean>
Adjust the url, username, and password properties, restart the application, and you're all set.

If you are using some other database:

Create and add a new data source bean definition to monitor-beans.xml file according to bean definitions above. For more specific information about driver class name and url patterns please refer to your database connector's documentation.

Note: The StatisticsJDBCInterceptor uses the following table structure in your database:
CREATE TABLE `statistics` (
	`id` INT NOT NULL PRIMARY KEY, 
	`statuscode` INT, 
	`time` VARCHAR(155), 
	`rule` VARCHAR(255), 
	`method` VARCHAR(50), 
	`path` VARCHAR(1000), 
	`client` VARCHAR(255), 
	`server` VARCHAR(255), 
	`reqcontenttype` VARCHAR(100), 
	`reqcontentlength` INT, 
	`respcontenttype` VARCHAR(100), 
	`respcontentlength` INT, 
	`duration` LONG 
);
If the table doesn't exist, it will be created. To modify the assumed structure, edit com.predic8.membrane.core.interceptor.statistics.util.JDBCUtil and rebuild Membrane Service Proxy from its source.

For more information, read the reference page of the statisticsJDBC element

Copyright © 2008-2015 predic8 GmbH
Moltkestr. 40, 53173 Bonn, Tel. +49 (228) 555 25 76-0