This sample explains how to:
- Create a statistics collector to collect statistics of operation invocations on WSO2 Governance Registry
- Publish that information from WSO2 Governance Registry to WSO2 Business Activity Monitor.
- Creating and deploying OSGi bundles that expose Declarative Services using the Apache Maven SCR Plugin.
This sample is similar to the Notifications Subscriber Sample and uses the same BAM Toolbox.
Once successfully deployed, this sample will report operation invocation statistics of WSO2 Governance Registry on the WSO2 Business Activity Monitor's dashboard. We will be reusing the code of the Handler Sample in this example. This sample requires Apache Maven and WSO2 Business Activity Monitor. See Installation Prerequisites for links on how to install Maven and Installing the Product for links on how to install WSO2 Business Activity Monitor.
1. Open the
repository/conf/carbon.xml file and set the port offset to 1.
2. Start the WSO2 Business Activity Monitor. See Starting the server.
3. Deploy the KPI_Registry_Activity.tbox BAM Toolbox to WSO2 Business Activity Monitor.
A BAM Toolbox is an installable archive which contains stream definitions, dashboard components and analytics for WSO2 Business Activity Monitor. The KPI_Registry_Activity.tbox is a pre-built BAM Toolbox based on the KPI Monitoring Sample example of WSO2 Business Activity Monitor, which is specifically designed for this sample. Read the KPI Monitoring Sample example of WSO2 Business Activity Monitor to learn how to make changes to this BAM Toolbox or create your own.
Select the ToolBox From File System option and fill in the URL of the KPI_Registry_Activity.tbox Toolbox. Then click on the Install button.
If the BAM Toolbox fails to install from the URL download the KPI_Registry_Activity.tbox Toolbox to your local file system and upload it.
4. Navigate to
samples/handler/src to find the source code of the Handler Sample.
5. Add the following dependencies to your POM file:
Project Object Model (POM) is an XML representation of a Maven project held in a file named pom.xml. You should find POM file by the name pom.xml inside
6. Comment-out the following exclusions in your POM file:
7. Add the following plugin to your POM file:
8. Add a new Java Class named
<GREG_HOME>/samples/handler/src/src/main/java/org/wso2/carbon/registry/samples/statistics/StatisticsCollectorServiceComponent.java with the following source:
9. Compile the source code by running the following command inside
mvn clean install will trigger an Apache Maven Build in your command line. This requires you having installed Apache Maven. See Installation Prerequisites for links on how to install it.
A successful run of Apache Maven will generate a report similar to the following:
10. Copy the <
org.wso2.carbon.registry.samples.handler-4.5.0.jar into <
11. Start the server and observe the command prompt. See Running the Product for more information.
12. After the server has started, log into the Management Console and perform various operations such such Managing WSDLs, Managing Subscriptions and Search. This should generate several events for BAM, and you should see lines similar to the following printed on your command prompt, which indicates that you events were successfully generated. For best results, create multiple user accounts and log in using different credentials while you perform operations.
13. Navigate to the Gadget Portal of WSO2 Business Activity Monitor to see the statistics corresponding to your operations.
A Statistics Collector must implement the
org.wso2.carbon.registry.core.statistics.StatisticsCollector interface. You can have more than one active Statistics Collector at any given time where each of them can be useful in one or many scenarios. For example, Statistics Collectors are used to capture Invocation Statistics visible via JMX.