Posts

WSO2 Governance Registry - Monitor database operations using log4jdbc

LOG4JDBC is a Java based database driver that can be used to log SQL and/or JDBC calls. So here I am going to show how to monitor JDBC operations on Governance Registry using log4jdbc.

Here I believe you have already configured Governance Registry instance with MySQL. If not, please follow the instruction available in the Governance Registry documentation.

1). Download the log4jdbc driver

 You can download log4jdbc driver from below location: https://code.google.com/p/log4jdbc/

2). Add log4jdbc driver

 Copy log4jdbc driver into CARBON_HOME/repository/components/lib directory.

3). Configure log4j.properties file.

Navigate to log4j.properties file located in CARBON_HOME/repository/conf/ directory and add below entry in to log4j.properties file.

# Log all JDBC calls except for ResultSet calls
log4j.logger.jdbc.audit=INFO,jdbc
log4j.additivity.jdbc.audit=false

# Log only JDBC calls to ResultSet objects
log4j.logger.jdbc.resultset=INFO,jdbc
log4j.additivity.jdbc.resultset=false

# Log only the SQL t…

WSO2 G-Reg Modify Subject of the Email Notification

WSO2 Governance Registry generates notifications for events triggered by various operations performed on resources and collections stored in the repository. Notifications can be consumed in a variety of formats including E-mail. The sample "E-mail NotificationCustomization" shows how we can modify the content of emails. It describes how to edit email body and restrict email notification to some email addresses.

Here I am going to extend that sample to modify Subject of the email.

private void editSubject(MessageContext msgContext, String newSubject) { ((Map) msgContext.getOptions().getProperty( MessageContext.TRANSPORT_HEADERS)).put(MailConstants.MAIL_HEADER_SUBJECT, newSubject); }

You will have to import "org.apache.axis2.transport.mail.MailConstants;" class and other related Java util classes as well.

When you are building the sample code, please follow the instructions available in the Governance Registry Sample Documentation.

WSO2 Governance Registry - Apply Tags using Handler

There can be scenarios, where users want to apply tags into their resources, while resource is inserted. I am writing this post based on my answer provided to this Stack Overflow question.

Question was on how to apply a tag into a service in WSO2 Governance Registry at the time of the service creation. We can use Registry Handler for achieving this requirement. Handlers are the well-known extension points in WSO2 Governance Registry.

"Handlers are pluggable components, that contain custom processing logic for handling resources. All handlers extend an abstract class named Handler, which provides default implementations for resource handling methods as well as a few utilities useful for concrete handler implementations."[WSO2 Governance Registry Docs]

I have modified handler sample, which is shipped with Governance Registry pack. Using above link please download the G-Reg pack and handler sample is located at GREG_HOME/samples/handler.

public void put(RequestContext requestC…

How to configure WSO2 G-Reg with ELB - Updated

This is the updated post for configuring WSO2 ELB 2.1.0 and G-Reg 4.6.0 releases. If you are using earlier releases, please refer the early post.

 When we are fronting WSO2 ELB(Elastic Load Balancer) for a WSO2 G-Reg(Governance Registry) node, all the incoming messages will go through ELB node and it will act as a HTTP and HTTPS proxy to GREG node. So when you configure ELB to the GREG front, GREG won't be able to access alone without the ELB.

1. Download WSO2 ELB and WSO2 GREG. Rename the extracted ELB as ELB-HOME and extracted GREG as GREG-HOME.

ELB Configuration 

2. Go to ELB-HOME/repository/conf/loadbalancer.conf and add the following entry. There can be multiple entries according to the clustering requirements.

governance {

domains   {
           wso2.governance.domain {
               tenant_range *;                group_mgt_port 4000;                mgt{                    hosts governance.local.wso2.com;                }            }        } }
 3. Update hosts files in node…

Manage SOAPAction of the Out Message

Image
When you are sending a request message to a backend service through WSO2 ESB, there could be some scenarios where you need to remove or change the SOAPAction header value.


Using header mediator and property mediator which are available in WSO2 ESB, we can remove SOAPAction or set it empty.

Set SOAPAction as Empty:
<header name="Action" value=""/> <property name="SOAPAction" scope="transport" value=""/>
Remove SOAPAction:
<header action="remove" name="Action"/> <property action="remove" name="SOAPAction" scope="transport"/>
Modify SOAPAction:

When setting SOAPAction one of the below approches can be used

1) .
<header name="Action" value="fixedAction"/>
2).
<header expression="xpath-expression" name="Action"/>
More Info: Header Mediator
TCPMon:

If we need to monitor the messages getting passed between ESB and…

Oracle JDBC driver for Maven

When you are adding the oracle jdbc driver to your project as a dependency, you will not be able to get it resolved from the public repository. This is happening due to license compatibility issue. Therefore you have to manual install Oracle JDBC driver into your local repo or private repo.

This is not limited to Oracle JDBC driver, there are some JARs which are not available in the public repos. Oracle JDBC drover can be downloaded from their web site
When you are adding a JAR to the repository or project, you can refer "Maven add jar without install" post or below command.

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=11.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar -DgeneratePom=true
 If you need to add JARs in to Central Repository this Maven guide will help.

How to get MySQL Database Size

While carrying out Performance Tests for WSO2 Governance Registry, I had to measure(calculate) MySQL database size. So here I am posting the query which I used to measure the MySQL database size, hoping this could be useful to someone.

SELECT table_schema "Database Name", Round(Sum(data_length + index_length) / 1024 / 1024, 3) "Database Size in MB" FROM   information_schema.tables  GROUP  BY table_schema;

Once this query is executed you can view the database size in formation like this::

mysql> SELECT table_schema "Database Name", Round(Sum(data_length + index_length) / 1024 / 1024, 3) "Database Size in MB" FROM   information_schema.tables  GROUP  BY table_schema;
+--------------------+---------------------+
| Database Name      | Database Size in MB |
+--------------------+---------------------+
| db11                       |               1.834 |
| db12                       |               1.834 |
+--------------------+-----------------…