servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache ServiceMix NMR > 11. Audit
Date Fri, 07 Jan 2011 09:22:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/3/_/styles/combined.css?spaceKey=SMX4NMR&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SMX4NMR/11.+Audit">11.
Audit</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~iocanel">Ioannis
Canellos</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        fixed a typo<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;/osgi:service&gt;
<br> <br></td></tr>
            <tr><td class="diff-changed-lines" >&lt;osgi:service <span
class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">ref=&quot;file-auditor&quot;&gt;</span>
<span class="diff-added-words"style="background-color: #dfd;">ref=&quot;jdbc-auditor&quot;&gt;</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >        &lt;osgi:interfaces&gt;
<br>            &lt;value&gt;org.apache.servicemix.nmr.audit.AuditorMBean&lt;/value&gt;
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <style type='text/css'>/*<![CDATA[*/
table.ScrollbarTable  {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color:
#f0f0f0}
table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}
table.ScrollbarTable td.ScrollbarPrevName {text-align: left;border: none;}
table.ScrollbarTable td.ScrollbarParent {text-align: center;border: none;}
table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;}
table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;}

/*]]>*/</style><div class="Scrollbar"><table class='ScrollbarTable'><tr><td
class='ScrollbarPrevIcon'><a href="/confluence/display/SMX4NMR/10.+Events"><img
border='0' align='middle' src='/confluence/images/icons/back_16.gif' width='16' height='16'></a></td><td
width='33%' class='ScrollbarPrevName'><a href="/confluence/display/SMX4NMR/10.+Events">10.
Events</a>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/SMX4NMR/Users%27+Guide"><img border='0' align='middle' src='/confluence/images/icons/up_16.gif'
width='8' height='8'></a></sup><a href="/confluence/display/SMX4NMR/Users%27+Guide">Users'
Guide</a></td><td width='33%' class='ScrollbarNextName'>&nbsp;<a
href="/confluence/display/SMX4NMR/12.+Configuration">12. Configuration</a></td><td
class='ScrollbarNextIcon'><a href="/confluence/display/SMX4NMR/12.+Configuration"><img
border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></div>
<p><a name="11.Audit-top"></a></p>

<h1><a name="11.Audit-11.Audit"></a>11. Audit</h1>

<h2><a name="11.Audit-Fileauditor"></a>File auditor</h2>

<p>First install the audit feature:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
smx@root:/&gt; features/install nmr-audit
</pre>
</div></div>

<p>Then create a file named <tt>deploy/servicemix-file-audit.xml</tt> with
the following content:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       <span class="code-keyword">xmlns:osgi</span>=<span class="code-quote">"http://www.springframework.org/schema/osgi"</span>
       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"&gt;

    <span class="code-tag">&lt;bean class=<span class="code-quote">"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"</span>
/&gt;</span>
    
    <span class="code-tag">&lt;bean id=<span class="code-quote">"file-auditor"</span>
class=<span class="code-quote">"org.apache.servicemix.nmr.audit.file.FileAuditor"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"directory"</span>
value=<span class="code-quote">"${servicemix.base}/data/audit/file"</span> /&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
    
    <span class="code-tag">&lt;osgi:service ref=<span class="code-quote">"file-auditor"</span>&gt;</span>
        <span class="code-tag">&lt;osgi:interfaces&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.api.event.Listener<span
class="code-tag">&lt;/value&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.api.event.ExchangeListener<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;/osgi:interfaces&gt;</span>
    <span class="code-tag">&lt;/osgi:service&gt;</span>

    <span class="code-tag">&lt;osgi:service ref=<span class="code-quote">"file-auditor"</span>&gt;</span>
        <span class="code-tag">&lt;osgi:interfaces&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.audit.AuditorMBean<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;/osgi:interfaces&gt;</span>
    <span class="code-tag">&lt;/osgi:service&gt;</span>

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<p>Here you go, all exchanges will be logged into the <tt>data/audit/file</tt>
directory.</p>

<p>Note that the file auditor is quite limited and only support counting the number
of exchanges, but the exchanges are written in plain text so you can view those easily.</p>

<h2><a name="11.Audit-JDBCauditor"></a>JDBC auditor</h2>

<p>First install the audit feature:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
smx@root:/&gt; features/install nmr-audit
</pre>
</div></div>

<p>Then, install the required database (we use HSQLDB here).  As there is no OSGi bundle
for this database, we use the <tt>wrap</tt> url handler to create one on the fly.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
smx@root:/&gt; osgi/install -s wrap:mvn:hsqldb/hsqldb/1.8.0.7
</pre>
</div></div>

<p>Then create a file named <tt>deploy/servicemix-jdbc-audit.xml</tt> with
the following content.  This example uses the HSQLDB database, but you can configure any DataSource.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       <span class="code-keyword">xmlns:osgi</span>=<span class="code-quote">"http://www.springframework.org/schema/osgi"</span>
       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"&gt;

    <span class="code-tag">&lt;manifest&gt;</span>
        DynamicImport-Package = *
    <span class="code-tag">&lt;/manifest&gt;</span>

    <span class="code-tag">&lt;bean class=<span class="code-quote">"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"</span>
/&gt;</span>
    
    <span class="code-tag">&lt;bean id=<span class="code-quote">"jdbc-auditor"</span>
class=<span class="code-quote">"org.apache.servicemix.nmr.audit.jdbc.JdbcAuditor"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"dataSource"</span>
ref=<span class="code-quote">"dataSource"</span> /&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
    
    <span class="code-tag">&lt;bean id=<span class="code-quote">"dataSource"</span>
class=<span class="code-quote">"org.hsqldb.jdbc.jdbcDataSource"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"database"</span>
value=<span class="code-quote">"jdbc:hsqldb:file:${servicemix.base}/data/audit/jdbc/hsqldb"</span>
/&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"user"</span>
value=<span class="code-quote">"sa"</span> /&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
    
    <span class="code-tag">&lt;osgi:service ref=<span class="code-quote">"jdbc-auditor"</span>&gt;</span>
        <span class="code-tag">&lt;osgi:interfaces&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.api.event.Listener<span
class="code-tag">&lt;/value&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.api.event.ExchangeListener<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;/osgi:interfaces&gt;</span>
    <span class="code-tag">&lt;/osgi:service&gt;</span>

    <span class="code-tag">&lt;osgi:service ref=<span class="code-quote">"jdbc-auditor"</span>&gt;</span>
        <span class="code-tag">&lt;osgi:interfaces&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.audit.AuditorMBean<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;/osgi:interfaces&gt;</span>
    <span class="code-tag">&lt;/osgi:service&gt;</span>

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<h2><a name="11.Audit-Luceneindexation"></a>Lucene indexation</h2>

<p>Any auditor can be wrapped in a lucene auditor to provide indexation and search in
audited exchanges.</p>

<p>Note that prior to installing the <tt>nmr-audit</tt> feature, you need
to install lucene bundle:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
smx@root:/&gt; osgi/install -s wrap:mvn:org.apache.lucene/lucene-core/2.4.1
</pre>
</div></div>

<p>If the feature has already been installed, you need to use the <tt>osgi/refresh</tt>
command.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
smx@root:/&gt; osgi/refresh
</pre>
</div></div>

<p>See the configuration below:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       <span class="code-keyword">xmlns:osgi</span>=<span class="code-quote">"http://www.springframework.org/schema/osgi"</span>
       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"&gt;

    <span class="code-tag">&lt;manifest&gt;</span>
        DynamicImport-Package = *
    <span class="code-tag">&lt;/manifest&gt;</span>

    <span class="code-tag">&lt;bean class=<span class="code-quote">"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"</span>
/&gt;</span>
    
    <span class="code-tag">&lt;bean id=<span class="code-quote">"jdbc-auditor"</span>
class=<span class="code-quote">"org.apache.servicemix.nmr.audit.jdbc.JdbcAuditor"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"dataSource"</span>
ref=<span class="code-quote">"dataSource"</span> /&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
    
    <span class="code-tag">&lt;bean id=<span class="code-quote">"lucene-auditor"</span>
class=<span class="code-quote">"org.apache.servicemix.nmr.audit.lucene.LuceneAuditor"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"delegatedAuditor"</span>
ref=<span class="code-quote">"jdbc-auditor"</span> /&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"luceneIndexer"</span>&gt;</span>
            <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.servicemix.nmr.audit.lucene.LuceneIndexer"</span>&gt;</span>
                <span class="code-tag">&lt;property name=<span class="code-quote">"directoryName"</span>
value=<span class="code-quote">"${servicemix.base}/data/audit/lucene/"</span>
/&gt;</span>
            <span class="code-tag">&lt;/bean&gt;</span>
        <span class="code-tag">&lt;/property&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
    
    <span class="code-tag">&lt;bean id=<span class="code-quote">"dataSource"</span>
class=<span class="code-quote">"org.hsqldb.jdbc.jdbcDataSource"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"database"</span>
value=<span class="code-quote">"jdbc:hsqldb:file:${servicemix.base}/data/audit/jdbc/hsqldb"</span>
/&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"user"</span>
value=<span class="code-quote">"sa"</span> /&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
    
    <span class="code-tag">&lt;osgi:service ref=<span class="code-quote">"lucene-auditor"</span>&gt;</span>
        <span class="code-tag">&lt;osgi:interfaces&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.api.event.Listener<span
class="code-tag">&lt;/value&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.api.event.ExchangeListener<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;/osgi:interfaces&gt;</span>
    <span class="code-tag">&lt;/osgi:service&gt;</span>
    
    <span class="code-tag">&lt;osgi:service ref=<span class="code-quote">"lucene-auditor"</span>&gt;</span>
        <span class="code-tag">&lt;osgi:interfaces&gt;</span>
            <span class="code-tag">&lt;value&gt;</span>org.apache.servicemix.nmr.audit.AuditorMBean<span
class="code-tag">&lt;/value&gt;</span>
        <span class="code-tag">&lt;/osgi:interfaces&gt;</span>
    <span class="code-tag">&lt;/osgi:service&gt;</span>

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<h3><a name="11.Audit-Queryfields"></a>Query fields</h3>

<ul>
	<li><tt>id</tt></li>
	<li><tt>mep</tt></li>
	<li><tt>status</tt></li>
	<li><tt>role</tt></li>
	<li><tt>properties.*</tt></li>
	<li><tt>in.content</tt></li>
	<li><tt>in.properties.*</tt></li>
	<li><tt>out.content</tt></li>
	<li><tt>out.properties.*</tt></li>
	<li><tt>fault.content</tt></li>
	<li><tt>fault.properties.*</tt></li>
</ul>


<h2><a name="11.Audit-Commands"></a>Commands</h2>

<p>A few commands are available to access the audited exchnanges:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
audit/count
audit/ids
audit/exchanges
audit/delete
audit/find
</pre>
</div></div>

<p>For example, to find all the exchanges with an ERROR status, try:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
smx@root:/&gt; audit/find <span class="code-quote">"status: error"</span>
</pre>
</div></div>


<p>The last command <tt>audit/find</tt> only works if lucene has been set
up as shown above.</p>

<p><a href="#11.Audit-top">top</a></p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SMX4NMR/11.+Audit">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=112297&revisedVersion=12&originalVersion=11">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SMX4NMR/11.+Audit?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message