Tuesday, November 23, 2010

Debug Carbon server when it is started as a daemon

WSO2 Carbon Server can be run as a daemon on Unix/Linux systems. Say for instance that you need to remote debug the server when it is started as a daemon. This blogpost will be discussing $subject.

1) Open up the wrapper.conf file.

heshan@heshan-ThinkPad:~/Dev/customer/wso2esb-3.0.1/bin$ vim ../repository/conf/wrapper.conf

2) Add following entries to the wrapper.conf.

wrapper.java.additional.20=-Xdebug
wrapper.java.additional.21=-Xnoagent
wrapper.java.additional.22=-Djava.compiler=NONE
wrapper.java.additional.23=-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005

3) Start the ESB as a daemon.

heshan@heshan-ThinkPad:~/Dev/customer/wso2esb-3.0.1/bin$ ./wso2server.sh start
Starting WSO2 ESB v3.0.1...

4) Start the debugger.

5) Monitor the log.

heshan@heshan-ThinkPad:~/Dev/customer/wso2esb-3.0.1/bin$ tail -f ../repository/logs/wrapper.log
INFO | jvm 1 | 2010/11/24 11:35:09 | object space 84224K, 76% used [0x00007fbfcff20000,0x00007fbfd3e0dff0,0x00007fbfd5160000)
STATUS | wrapper | 2010/11/24 11:35:09 | <-- Wrapper Stopped STATUS | wrapper | 2010/11/24 11:45:46 | --> Wrapper Started as Daemon
WARN | wrapper | 2010/11/24 11:45:46 | ------------------------------------------------------------------------
WARN | wrapper | 2010/11/24 11:45:46 | The JVM is being launched with a debugger enabled and could possibly be
WARN | wrapper | 2010/11/24 11:45:46 | suspended. To avoid unwanted shutdowns, timeouts will be disabled,
WARN | wrapper | 2010/11/24 11:45:46 | removing the ability to detect and restart frozen JVMs.
WARN | wrapper | 2010/11/24 11:45:46 | ------------------------------------------------------------------------
STATUS | wrapper | 2010/11/24 11:45:46 | Launching a JVM...
INFO | jvm 1 | 2010/11/24 11:45:46 | Listening for transport dt_socket at address: 5005
INFO | jvm 1 | 2010/11/24 11:45:56 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
INFO | jvm 1 | 2010/11/24 11:45:56 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
INFO | jvm 1 | 2010/11/24 11:45:56 |
INFO | jvm 1 | 2010/11/24 11:45:56 | [2010-11-24 11:45:56,845] INFO - Main Initializing system...

Now you have successfully debugged the Carbon Server, when it is started as a daemon.

Friday, October 29, 2010

WSO2 Basketball finals 2010

QUALIFYING MATCHES
The 3rd annual WSO2 Basketball tournament was held over the month of October. We had 4 teams and 6 qualifying matches leading up to the finals. Wild Boars and Legions were the teams with the leading scores and they were chosen to be in the finals. When comparing with last 2 years, this time around every team had a balanced set of players. It can be seen by results of the preliminary round matches, where 3 teams had won 2 out of 3 matches they faced. Therefore, we had to choose the finalists by getting the accumulated scores of each team.

THE TEAMS
The Legions were led by our CEO, Dr. Sanjiva Weerawarna and the Wild Boars were led by our VP of Engineering, Samisa Abeysinghe.

====================================================
Legions | Wild Boars |
====================================================
Amal Rangana |Amila Suriyarachchi |
Chamara Silva |Asanka Abeysinghe (VC) |
Chanaka Jayasena |Asela Pathberiya |
Danushka Menikkumbura |Deependra Ariyadewa |
Flora Ariyapala |Dimuthu Leelarathne |
Gayani Rajanayake |Hasmin Abdul Cader |
Isuru Suriarachchi |Heshan Suriyarachchi |
Janath Sivayoganathan |Milinda Lakmal Pathirage |
Kalpani Wanigaratne |Nandika Jayawardana |
Mahesh Marcus |Rajika Kumasiri |
Sanjiva Weerawarana (C) |Samisa Abeysinghe (C) |
Srinath Perera |Sumedha Rubasinghe |
Tharindu Mathew |Udeshika Ratnavira |
Thilina Buddika |Thilanga Pitigala |
Waruna Ranasinghe |Anjana Fernando |
Miyuru Daminda |Yasith Nakandana |
Kasun Indrasiri |Lavi De Silva |
Gayani Marasinghe |Sanjaya Vithanagama |
Pavithra Madurangi |Denis Perera |
Arjuna Samaraweera |Shammi Jayasinghe |
Asiri Rathnayake |P.K.A. Thilini Ishaka |
Eshara Kalpanie Fonseka |Kathiravelu Pradeeban |
Janaka Ranabahu |Udayanga Wickramasinghe |
Sarasi Madushika |Pradeep Fernando |
Nirdesha Munasinghe |Hasini Gunasinghe |
Charith Wickramarachchi |Hasini Yatawatte |
Dinusha Dilrukshi |Sanjeewa Mallalgoda |
Manisha Ellaperuma | |
Meeyoni Fernando | |
====================================================

THE FINAL
It was a rain hit final and we played in our usual outdoor Basketball court - the car-park ;). Eventhough it was raining we could see the crowd standing around the court and cheering for their favourites.

The Legions started playing very aggressively from the word go and they were determind to not let the Championship slip away from them. Wildboars on the other hand was equal to the task and did not want to repeat the 2009 finals (in which WBs became runners up). It was an evenly contested match and The Legions were leading at half time whisle. Although they were leading, the Wild Boars were not too far behind (I can't recall the half-time score).

Then we started the second half. In the second half Wild Boars caught up to Legions score. I remember a point where the scores were levelled at 36-all. From this point onwards, non of the two teams didn't let the other take the lead for more than 2 points. It was showing the symptoms of going for an extra time ending.

FINAL WORKOUT
As the game progressed, I was getting the feeling that the game should be finished by now. So I asked Pumika who was near the stop clock, "how much time left?". She told me 30 seconds. I instantly thought of getting a timeout, but since we had the ball in our hand and we were attacking, I didnt want to take a timeout. (At that point if I took a timeout, it will inturn let the Legions know of the stop clock. Therefore, I opted not to take a timeout :) )

Asanka was controlling the ball at that time. I shouted at him "SHOOT! SHOOT!" (BTW, the scores were levelled at this point, 42-all). I don't know whether he heard my screms in the middle of the roar from the crowd. Anjana, Ude and I, was guarded by the defenders. Asanka, cleverly dribbled towards the baseline, which resulted in two defenders going towrds him to guard his move. That move, freed Samisa (the defender that should guard Samisa was now defending Asanka). Then Asanka passed the ball back to Samisa, who hit a long range 2 pointer to seal the win for the Wild Boars. That marked the end of a nail biting final. A final which I will remember for a long time. :)



Hats off to Legions for giving such a good game and in my book, both the teams were winners that night. They both fought hard to win the Championship. If you have a look back at the Legions past performances, this is a significant improvement from their side.

SCORE SHEETS

==============================================================
Date | Teams |Score
==============================================================
Wednesday 6th 4.00 pm | Cloud bots Vs. Titans |31:53
Thursday 7th 4.00 pm | Legion Vs. Wild Boars |23:34
Tuesday 12th 4.00 pm | Titans Vs. Wild Boars |33:28
Thursday 14th 4.00 pm | Cloud bots Vs. Legion |22:54
Tuesday 19th 4.00 pm | Cloud bots Vs. Wild Boars |34:61
Thursday 21st 4.00 pm | Titans Vs. Legion |29:40
Tuesday 26th 4.00 pm | Cloud bots Vs. Titans |41:72
Thursday 28th 7.00 pm | Wild Boars Vs. Legions |44:42
==============================================================

OBSERVAIONS
Piyumika was the main person responsible for organizing this year's tournament. She had given attention to detail in organizing this very successful event which everyone enjoyed very much. I take this opportunity to thank (on behalf of all the players) Piyumika and her team for making this a memorable night. Specially the idea to bring in a face painter added color to the event :).

I take the this opportunity to thank the crowd (who came to cheer for us or against us) who supported the players throughout this tournament. If it wasn't for ya'll it wont be an entertaining tournament like this.

As Isuru pointed out the other day, we did not have any serious injuries (broken bones, torn muscles, etc:) ) during this tournament. That means we are starting to play real Basketball and we have moved away from playing the Rugby+Basketball [2] hybrid, that we were used to play :D.

I am finishing off this post with an extract from a Fort Minor song.

This is ten percent luck, twenty percent skill
Fifteen percent concentrated power of will
Five percent pleasure, fifty percent pain
And a hundred percent reason to remember the name


Related Posts
[1] - http://heshans.blogspot.com/2008/10/internship-wso2.html
[2] - http://heshans.blogspot.com/2009/10/basketball-wso2-how-to-survive.html

Pictures courtesy of Chinthana Wilmuna.

Monday, October 25, 2010

Generate custom Error messages with WSO2 ESB

In this blogpost we will be looking at how to generate a soap fault using the makefault mediator. In addition to that I will show how to embed a custom message within that soap fault. Inorder to achieve this goal we will be using the makefault mediator and a script mediator.

The Synapse configuration used:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="detailsTransformScript" src="file:repository/samples/resources/script/detailTransform.js"/>
<sequence name="myFaultHandler">
<property name="uniqueKey" value="123" scope="default" type="STRING"/>
<property name="customErrorCode" value="8719" scope="default" type="STRING"/>
<property name="customErrorText" value="Issue has " scope="default" type="STRING"/>
<property name="customTime" expression="get-property('SYSTEM_DATE')" scope="default" type="STRING"/>
<script language="js" key="detailsTransformScript" function="transformDetail"/>
<log level="custom">
<property name="Detail" expression="get-property('customErrorDetail')"/>
</log>
<makefault version="soap11">
<code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
<reason expression="get-property('ERROR_MESSAGE')"/>
<detail expression="get-property('customErrorDetail')"/>
</makefault>
<send/>
</sequence>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default "fault" sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</sequence>
<sequence name="main" onError="myFaultHandler">
<in>
<switch xmlns:m0="http://services.samples" source="//m0:getQuote/m0:request/m0:symbol">
<case regex="MSFT">
<send>
<endpoint name="endpoint_urn_uuid_F3FC39CF93F681A11649593938524451942754528">
<address uri="http://bogus:9000/services/NonExistentStockQuoteService"/>
</endpoint>
</send>
</case>
<case regex="SUN">
<send>
<endpoint name="endpoint_urn_uuid_F3FC39CF93F681A1164959398253284-1608236576">
<address uri="http://localhost:9009/services/NonExistentStockQuoteService"/>
</endpoint>
</send>
</case>
</switch>
<drop/>
</in>
<out>
<send/>
</out>
</sequence>
</definitions>

The javascript file used in the script mediator:

function transformDetail(mc) {
var symbol = mc.getPayloadXML()..*::Code.toString();
var errorCode = mc.getProperty("customErrorCode");
var errorText = mc.getProperty("customErrorText");
var time = mc.getProperty('customTime');
mc.setProperty("customErrorDetail", <AppErrorCode><TimeStamp>{time}</TimeStamp><ErrorCode>{errorCode}</ErrorCode><ErrorText>{errorText}</ErrorText></AppErrorCode>);
}

Instructions to run the sample.
1) Copy the attached javascript file to ESB_HOME/repository/samples/resources/script/ directory.

2) Startup the ESB instance. Copy the attached synapse configuration to source view of the Management UI and hit update.

3) Start the Axis2 server and deploy the SimpleStockQuoteService if not already done.

4) Execute the client using following command.

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT

5) Monitor the response message with TCPMon.

HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset=UTF-8
Host: 127.0.0.1:8281
SOAPAction: "urn:getQuote"
Date: Thu, 21 Oct 2010 09:52:23 GMT
Transfer-Encoding: chunked

338
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:MessageID>urn:uuid:952C448142FB1B1FE925278283667424-1166645935</wsa:MessageID>
<wsa:Action>urn:getQuote</wsa:Action>
<wsa:RelatesTo>urn:uuid:6DDD0BCE4CDCFB5AFD1287654743750</wsa:RelatesTo>
</soapenv:Header>
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:tns="http://www.w3.org/2003/05/soap-envelope">tns:Receiver</faultcode>
<faultstring>Connection refused or failed for : bogus:9000, IO Exception occured : bogus</faultstring>
<detail>
<AppErrorCode>
<TimeStamp>10/21/10 3:22 PM</TimeStamp>
<ErrorCode>8719</ErrorCode>
<ErrorText>A custom issue has occured</ErrorText>
</AppErrorCode></detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>0

As you can see we have added a custom details element which is containing some information that you would like to generate.

Further Reading

[1] - Refer transport ERROR codes in https://svn.apache.org/repos/asf/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java

[2] - Property Mediator section of the WSO2 ESB Configuration language
http://wso2.org/project/esb/java/3.0.1/docs/configuration_language.html#property

[3] - WSO2 ESB error handling samples.
http://wso2.org/project/esb/java/3.0.1/docs/samples/message_mediation_samples.html#Sample4
http://wso2.org/project/esb/java/3.0.1/docs/samples/message_mediation_samples.html#Sample5

[4] - We are having built in Error Codes for transport related errors. Say for instance that you need to handle an error related to an XML format error. That kind of issues can be resolved by using fault handlers.
eg: If a sequence fail in an XSLT transformation phase due to to an XML format error, you can register a fault handler for a sequence to handle it. For more information read Error Handling with Sequences and Proxy Services .

Tuesday, October 19, 2010

Send HTML format email from WSO2 ESB

1. Enable mail transport sender and transport listener in the axis2.xml.

<transportSender name="mailto" <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<parameter name="mail.smtp.host">smtp.gmail.com</parameter>
<parameter name="mail.smtp.port">587</parameter>
<parameter name="mail.smtp.starttls.enable">true</parameter>
<parameter name="mail.smtp.auth">true</parameter>
<parameter name="mail.smtp.user">synapse.demo.0</parameter>
<parameter name="mail.smtp.password">mailpassword</parameter>
<parameter name="mail.smtp.from">synapse.demo.0@gmail.com</parameter>
</transportSender>

<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener"/>

2. Register the ApplicationXMLFormatter as the formatter for text/html content type in the axis2.xml

&lt:messageFormatter contentType="text/html" class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>

3. In the mediation sequence, set the messageType property as well as the ContentType property to text/html (Setting both parameters is crucial to get this working. The messageType parameter is looked up by the mail transport to select the correct formatter. The other property is used by the formatter to set the right content type on the outgoing message.)

The sample proxy configuration is attached for your reference.

<proxy name="StockQuoteProxy" transports="http" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property name="Subject" value="Custom Subject for Response" scope="transport"/>
<property name="messageType" value="text/html" scope="axis2"/>
<property name="ContentType" value="text/html" scope="axis2"/>
<property name="OUT_ONLY" value="true"/>
<script language="js"><![CDATA[
mc.setPayloadXML(<h1>WSO2 ESB Rocks!</h1>);
]]></script>
<log level="full"/>
<send>
<endpoint>
<address uri="mailto:test@test.com"/>
</endpoint>
</send>
</inSequence>
</target>
</proxy>

4. To test the sample, simply send a request to the sample proxy service using the sample Axis2 client. That will send an e-mail with in-line HTML content to the target endpoint.

eg.

wso2esb-3.0.0/samples/axis2Client$ ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy

Friday, October 8, 2010

Thursday, September 30, 2010

Build WSO2 Stratos ESB from source

Following blogpost will discuss how to build WSO2's Stratos ESB (aka Cloud ESB) from source.

1. First build carbon trunk upto features. Please follow my earlier post on building WSO2 ESB from source.

2. Checkout WSO2 Stratos source.

svn co https://svn.wso2.org/repos/wso2/trunk/stratos

Then following directories/files will be checked into your file system.

.
|-- build
|-- components
|-- features
|-- pom.xml
|-- samples
|-- services
`-- setup

3. Build Stratos components project.

heshan@heshan-laptop:~/Dev/trunk/stratos/components$ mvn clean install -Dmaven.test.skip=true

4. Build Strtos features project.

heshan@heshan-laptop:~/Dev/trunk/stratos/features$ mvn clean install -Dmaven.test.skip=true

5. Build Stratos Manager.

heshan@heshan-laptop:~/Dev/trunk/stratos/services/manager$ mvn clean install -Dmaven.test.skip=true

6. Build Stratos ESB.

heshan@heshan-laptop:~/Dev/trunk/stratos/services/esb$ mvn clean install -Dmaven.test.skip=true

7. Run the setup script.

heshan@heshan-laptop:~/Dev/trunk/stratos/setup$ ./setup.sh

8. Create the necessary databases.

mysql>CREATE DATABASE stratos_db;

mysql>CREATE DATABASE WSO2CARBON_DB;

mysql>CREATE DATABASE billing;

Create users and give necessary user-permssions.

mysql>CREATE USER 'wso2stratos'@'localhost' IDENTIFIED BY 'wso2stratos';
mysql>GRANT ALL ON *.* TO 'wso2stratos'@'localhost';

mysql>CREATE USER 'billing'@'localhost' IDENTIFIED BY 'billing';
mysql>GRANT ALL ON *.* TO 'billing'@'localhost';

Create tables.

heshan@heshan-laptop:~/Dev/trunk/stratos/services/manager/modules/distribution/target/wso2stratos-manager-1.0.0-SNAPSHOT/dbscripts$ mysql -u root -p < billing-mysql.sql billing

9. Start the Stratos Manager.
NOTE: Server should be started with -Dsetup option in the first time.

heshan@heshan-laptop:~/Dev/trunk/stratos/services/manager/modules/distribution/target/wso2stratos-manager-1.0.0-SNAPSHOT/bin$ ./wso2server.sh -Dsetup

10. Start Stratos ESB.
NOTE: Server should be started with -Dsetup option in the first time.

heshan@heshan-laptop:~/Dev/trunk/stratos/services/esb/modules/distribution/target/wso2stratos-esb-1.0.0-SNAPSHOT/bin$ ./wso2server.sh -Dsetup

11. Stop the above servers. Then startup the both the servers again without -Dsetup option.

heshan@heshan-laptop:~/Dev/trunk/stratos/services/manager/modules/distribution/target/wso2stratos-manager-1.0.0-SNAPSHOT/bin$ ./wso2server.sh
heshan@heshan-laptop:~/Dev/trunk/stratos/services/esb/modules/distribution/target/wso2stratos-esb-1.0.0-SNAPSHOT/bin$ ./wso2server.sh

12. Create a Tenent by logging into the Stratos Manager. Then using the credentials obtained, you can log into the Stratos ESB.

Friday, September 10, 2010

Migrate Synapse Configuration from 1.2 to 2.0

The current namespace of the synapse-2.0 trunk is http://synapse.apache.org/ns/2010/04/configuration. The earlier namespace of synapse-1.2 was http://ws.apache.org/ns/synapse. Therefore you may encounter some errors, when running a synapse configuration of a 1.2 release against a trunk build(ie. synapse-2.0.0-SNAPSHOT). Since the Synapse configuration has undergone some configuration changes, merely changing the namespace of the the old synapse configuration wont help you to solve your problem.

That's why Synapse ships a migration tool for migrating a 1.2 configuration to a 2.0 configuration. Ruwan has written the xslt transformation for the above. You can find it in the Synapse trunk.

Recently I had to update the Synapse sample configurations of WSO2 ESB's trunk. This tool made my life a lot easier during the migration process. I modified the sample migrator to suit my purpose. I am sharing the code here, if you need to migrate the synapse configurations in bulk.

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
*
*/
public class ConfigurationMigrator {

private static final String MIGRATOR_XSLT_PATH
= "modules/migrator/src/main/resources/synapse-configuration-migrator.xslt";

public static int confgNumber [] = new int []
{0,1,2,3,4,5,6,7,8,9,10,11,
50,51,52,53,54,55,56,57,58,
100,101,102,
150,151,152,153,154,155,
200,201,202,
250,251,252,253,254,255,256,257,258,259,
260,261,262,264,265,
300,
350,351,352,353,354,
360,361,362,363,
370,371,372,
380,381,
390,391,
400,420,430,
500,501,502,503,504,
550,551,
600,601,602,603,604,605,606,
652,654};

public static void doTransform(String xmlFile, String xslFile, String outFile)
throws TransformerException, IOException {

FileReader xslFileReader = new FileReader(xslFile);
StreamSource xslStreamSource = new StreamSource(xslFileReader);

FileReader xmlFileReader = new FileReader(xmlFile);
StreamSource xmlStreamSource = new StreamSource(xmlFileReader);

FileWriter outFileWriter = new FileWriter(outFile);
StreamResult outStreamResult = new StreamResult(outFileWriter);

TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(xslStreamSource);

transformer.transform(xmlStreamSource, outStreamResult);
outFileWriter.flush();
}

public static void migrateAllConfigs(String source, String destination){
System.out.println("\n\t#######################################################");
System.out.println("\t# Apache Synapse - Configuration Migration #");
System.out.println("\t#######################################################");

System.out.println("\n[INFO] Migration STARTED");

for (int aConfgNumber : confgNumber) {
try {
System.out.println("[INFO]Migrating synapse configuration : " + aConfgNumber);
doTransform(source + aConfgNumber + ".xml", MIGRATOR_XSLT_PATH, destination + aConfgNumber +".xml");

} catch (TransformerException e) {
handleException("Migration FAILED\n\t" + e.toString());
} catch (IOException e) {
handleException("Migration FAILED\n\t" + e.toString());
}
}

System.out.println("[INFO] Migration COMPLETED");

}

public static void main(String args[]) {
migrateAllConfigs("/home/heshan/Dev/trunk/carbon/products/esb/modules/samples/src/main/conf/synapse/synapse_sample_",
"/tmp/synapse-config/synapse_sample_");
}

private static void handleException(String message) {
System.out.println("[ERROR] " + message);
}
}

Thursday, September 9, 2010

WSO2 Enterprise Service Bus (ESB) 3.0.1 Released

The WSO2 ESB team is pleased to announce the release of version 3.0.1 of the Open Source Enterprise Service Bus (ESB).

WSO2 ESB is a fast, lightweight and user friendly open source Enterprise Service Bus (ESB) distributed under the Apache Software License v2.0. WSO2 ESB allows system administrators and developers to easily configure message routing, intermediation, transformation, logging, task scheduling, fail over routing and load balancing. It also supports transport switching, eventing, rule based mediation and priority based mediation for advanced integration requirements. The ESB runtime is designed to be completely asynchronous, non-blocking and streaming based on the Apache Synapse mediation engine.

WSO2 ESB 3.0.1 is developed on top of the revolutionary WSO2 Carbon platform (Middleware a' la carte), an OSGi based framework that provides seamless modularity to your SOA via componentization. This release also contains many new features and a range of optional components (add-ons) that can be installed to customize the behavior of the ESB. Further, any existing features of the ESB which are not required to your environment can be easily removed using the underlying provisioning framework of Carbon. In brief, WSO2 ESB can be fully customized and tailored to meet your exact SOA needs.

You can download this distribution from http://wso2.org/downloads/esb and give it a try.

How to Run

  1. Extract the downloaded zip
  2. Go to the bin directory in the extracted folder
  3. Run the wso2server.sh or wso2server.bat as appropriate
  4. Point your browser to the URL https://localhost:9443/carbon
  5. Use "admin", "admin" as the username and password to login as an admin and create a user account
  6. Assign the required permissions to the user through a role
  7. If you need to start the OSGi console with the server use the property -DosgiConsole when starting the server. The INSTALL.txt file found on the installation directory will give you a comprehensive set of options and properties that can be passed into the startup script
  8. Sample configurations can be started by the wso2esb-samples script passing the sample number with the -sn option (Please have a look at the samples guide for more information, on running samples)

New Features of WSO2 ESB 3.0.1

There are no new features in this release. This is a bug fix release. See the section "Bugs Fixed in WSO2 ESB 3.0.1" for more information.

Key Features of WSO2 ESB

  • Proxy services - facilitating synchronous/asynchronous transport, interface (WSDL/Schema/Policy), message format (SOAP 1.1/1.2, POX/REST, Text, Binary), QoS (WS-Addressing/WS-Security/WS-RM) and optimization switching (MTOM/SwA).
  • Non-blocking HTTP/S transports based on Apache HttpCore-NIO for ultrafast execution and support for thousands of connections at high concurreny with constant memory usage.
  • Built in Registry/Repository, facilitating dynamic updating and reloading of the configuration and associated resources (e.g. XSLTs, XSD, WSDL, Policies, JS configurations ..)
  • Easily extendable via custom Java classes (mediator and command)/Spring configurations, or BSF Scripting languages (Javascript, Ruby, Groovy, etc.)
  • Built in support for scheduling tasks using the Quartz scheduler.
  • Load-balancing (with or without sticky sessions)/Fail-over, and clustered Throttling and Caching support
  • WS-Security, WS-Reliable Messaging, Caching & Throttling configurable via (message/operation/service level) WS-Policies
  • Lightweight, XML and Web services centric messaging model
  • Support for industrial standards (Hessian binary web service protocol/ Financial Information eXchange protocol and optional Health Level-7 protocol)
  • Enhanced support for the VFS (File/FTP/SFTP), JMS, Mail transports with optional TCP/UDP transports and transport switching among any of the above transports
  • Support for message splitting & aggregation using the EIP and service callouts
  • Database lookup & store support with DBMediators with reusable database connection pools
  • WS-Eventing support with event sources and event brokering
  • Rule based mediation of the messages using the Drools rule engine
  • Transactions support via the JMS transport and Transaction mediator for database mediators
  • Internationalized GUI management console with user management for configuration development
  • Integrated monitoring support with statistics, configurable logging and tracing
  • JMX monitoring support and JMX management capabilities like, Graceful/Forceful shutdown/restart

Bugs Fixed in This Release

This release of WSO2 ESB comes with a number of bug fixes, both in the base framework and the ESB specific componenents. All the issues which have been fixed in ESB 3.0.1 are recorded at following locations:

Known Issues

  • Endpoint UI does not support selecting already existing endpoints as child endpoints when creating load balance/failover endpoints
  • HTTP GET requests performed on an endpoint that has a trailing '/' character, do not work properly
  • SOAP tracer does not work when the message relay is activated
  • The sequence editor and the built-in XML editors do not work properly on Google Chrome

All the open issues pertaining to WSO2 ESB 3.0 are reported at following locations:

How You Can Contribute

Mailing Lists

Join our mailing list and correspond with the developers directly.

Reporting Issues

WSO2 encourages you to report issues and your enhancement requests for the WSO2 ESB using the public JIRA.

You can also watch how they are resolved, and comment on the progress..

Discussion Forums

Alternatively, questions could be raised using the forums available.

WSO2 ESB Forum : Discussion forum for WSO2 ESB developers/users

Support

We are committed to ensuring that your enterprise middleware deployment is completely supported from evaluation to production. Our unique approach ensures that all support leverages our open development methodology and is provided by the very same engineers who build the technology.

For more details and to take advantage of this unique opportunity please visit http://wso2.com/support.

For more information about WSO2 ESB please see http://wso2.com/products/enterprise-service-bus.

-- The WSO2 ESB Team --

Thursday, September 2, 2010

Win a free trip to WSO2 Con

The sponsorship includes:

* Return air ticket, including international!
* 5 nights hotel accommodation
* Ground transport
* US $50 per Diem
* Free pass to WSO2Con 2010
* Free pass to two day special Technical Workshop
* Invitation to VIP Gala Dinner Celebration
* Invitation to WSO2 5 Year Celebration Party

For more information visit [1].

[1] - http://wso2.org/wso2con2010-sponsorship

Wednesday, September 1, 2010

WSO2 Con 2010

WSO2 Con 2010 will be held at HNB Towers, Colombo on 14th and 15th September. For more information visit WSO2Con website.


Tuesday, July 20, 2010

Sending UTF-16 messages through Synapse

When fixing SYNAPSE-662 and SYNAPSE-670, I had to send UTF-16 messages to the SimpleStockQuoteService to verify the fixes. Following are the sample configuration and client code that I used to verify the fixes.

1. Start the Synapse ESB with the following configuration.

<definitions xmlns="http://ws.apache.org/ns/synapse">
<switch source="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples/xsd">
<case regex="IBM">
<!-- the property mediator sets a local property on the *current* message -->
<property name="symbol" value="Great stock - IBM"/>
</case>
<case regex="MSFT">
<property name="symbol" value="Are you sure? - MSFT"/>
</case>
<default>
<!-- it is possible to assign the result of an XPath expression as well -->
<property name="symbol"
expression="fn:concat('Normal Stock - ', //m0:getQuote/m0:request/m0:symbol)"
xmlns:m0="http://services.samples/xsd"/>
</default>
</switch>

<log level="custom">
<!-- the get-property() XPath extension function allows the lookup of local message properties
as well as properties from the Axis2 or Transport contexts (i.e. transport headers) -->
<property name="symbol" expression="get-property('symbol')"/>
<!-- the get-property() function supports the implicit message headers To/From/Action/FaultTo/ReplyTo -->
<property name="epr" expression="get-property('To')"/>
</log>

<!-- Send the messages where they are destined to (i.e. the 'To' EPR of the message) -->
<send/>
</definitions>


2. Start the Axis2 server and deploy the SimpleStockQuoteService.

3. Use the following axis2 client (which generates a UTF-16 message) to invoke the service.

package org.wso2.esb;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;

import java.lang.*;

public class MyClient {
public static OMElement createPayload(){
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
OMElement method = fac.createOMElement("getQuote", omNs);
OMElement value1 = fac.createOMElement("request", omNs);
OMElement value2 = fac.createOMElement("symbol", omNs);

value2.addChild(fac.createOMText(value1, "IBM"));
value1.addChild(value2);
method.addChild(value1);
return method;
}

public static void main(String args[]){
OMElement payload = createPayload();
ServiceClient serviceclient;

ConfigurationContext configurationContext = null;
try {
configurationContext = ConfigurationContextFactory.
createConfigurationContextFromFileSystem("/home/heshan/Dev/trunk/synapse/modules/distribution/target/synapse-2.0.0-SNAPSHOT/samples/axis2Client/client_repo",
"/home/heshan/Dev/trunk/synapse/modules/distribution/target/synapse-2.0.0-SNAPSHOT/samples/axis2Client/client_repo/conf/axis2.xml");

serviceclient = new ServiceClient();
Options opt = new Options();

opt.setTo(new EndpointReference ("http://localhost:8281/services/StockQuote"));
opt.setAction("urn:getQuote");
opt.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING,"UTF-16");
opt.setSoapVersionURI(org.apache.axiom.soap.SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
serviceclient.setOptions(opt);

OMElement ome = serviceclient.sendReceive(payload);
System.out.println("The output is : " + ome);

} catch (AxisFault axisFault) {
axisFault.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.

}

}
}

Wednesday, July 14, 2010

Extend the Axis2 Framework to Support JVM Based Scripting Languages

This article explains how to extend the Axis2 framework to support Java Virtual Machine (JVM) based scripting languages such as Jython, JRuby, etc. It provides a high level overview of the subject, covering some key concepts of Apache Axis2 and how it can be used to come up with an extension to a JVM based scripting language. After going through this article, a developer will be able to extend the Axis2 framework to support the JVM based scripting language of his or her choice.

If you are interested, read the full article on InfoQ.com.

I take this opportunity to thank Nandika for doing the technical review and Charles Humble for doing the editorial review.

Tuesday, June 22, 2010

Build WSO2 ESB from source

This post will discuss how to build WSO2 ESB[1] from the WSO2 Carbon[2] trunk.

1) Checkout WSO2 Carbon project's trunk.

heshan@heshan-laptop:~/Dev/trunk/$ svn co https://svn.wso2.org/repos/wso2/trunk/carbon

Following directories/files would be checked-out to your file system.

carbon
|-- components
|-- core
|-- dependencies
|-- features
|-- orbit
|-- pom.xml
|-- products

2) Build the dependencies for ESB project.

heshan@heshan-laptop:~/Dev/trunk/carbon/dependencies$ mvn clean install -Dproduct=esb

Then the following dependencies will be built. If you encounter any build errors, try and build each project one at a time :)

dependencies
|-- abdera
|-- axiom
|-- axis2
|-- wss4j
|-- carbon-p2-plugin
|-- commons/caching
|-- commons/eventing
|-- commons/throttle
|-- commons/xkms
|-- p2
|-- rampart
|-- rhino
|-- sandesha
|-- savan
|-- synapse
|-- transports
|-- commons-vfs

Carbon Dependencies :-
Carbon platform makes use of already existing open source projects rather than trying to re-invent the wheel. We use popular and matured open source projects like apache axiom, axis2, synapse etc which fuel the very heart of the carbon platform. Dependencies contains all these open source projects that the carbon platform makes use of adding more value to them.

3) Build Carbon Orbit for ESB project.

heshan@heshan-laptop:~/Dev/trunk/carbon/orbit$ mvn clean install -Dproduct=esb
Carbon Orbit :-
WSO2 Carbon uses OSGi as its underlying modularization technology. But Many 3rd party open source libraries does not exists in osgi form (ie. in osgi bundle form). Therefore to introduce them to the carbon platform, we wrap-around them to make them proper OSGI bundles (They will be useful to any OSGI environment like felix, knoplerfish etc). Carbon-orbit project contains all these third party bundles.

4) Build Carbon Core for ESB project.

heshan@heshan-laptop:~/Dev/trunk/carbon/core$ mvn clean install -Dproduct=esb
Carbon Core :-
This is where we create the base for our platform. Everything runs on top of this base. From the simple OSGi framework to the UI framework, all the critical technologies for the platform are implemented here.

5) Build Carbon Components for ESB project.

heshan@heshan-laptop:~/Dev/trunk/carbon/components$ mvn clean install -Dproduct=esb
Carbon Components :-
Components module contains the main functionalities that are introduced by each and every product in addition to to the core level features. Among the close to 100 components each adds value to the product in a different way than the next. Some will enhance the security while some may just provide vital tools to monitor the health of the system.

6) Build Carbon Features for ESB project.

heshan@heshan-laptop:~/Dev/trunk/carbon/features$ mvn clean install -Dproduct=esb
Carbon Features :-
Equinox P2 has been integrated with WSO2 Carbon platform to enable provisioning capabilities. This enables you to extend or enhance your carbon platform with more functionalities or just strip out the irrelevant features which suits your context.

7) Build WSO2 ESB product.

heshan@heshan-laptop:~/Dev/trunk/carbon/products/esb$ mvn clean install
Carbon Product :-
Products module contains all the products ranging from ESB to BRS.

8) When the build is successful move to target folder inside esb project.

heshan@heshan-laptop:~/Dev/trunk/carbon/products/esb/modules/distribution/target$ ls
pom-transformed.xml wso2esb-3.0.0-SNAPSHOT wso2esb-3.0.0-SNAPSHOT-docs.zip wso2esb-3.0.0-SNAPSHOT.zip

Then unzip the SNAPSHOT.

heshan@heshan-laptop:~/Dev/trunk/carbon/products/esb/modules/distribution/target$ unzip wso2esb-3.0.0-SNAPSHOT.zip

Start the ESB server

heshan@heshan-laptop:~/Dev/trunk/carbon/products/esb/modules/distribution/target/wso2esb-3.0.0-SNAPSHOT/bin$ ./wso2server.sh

Now you have successfully built and started a WSO2 ESB build from Carbon trunk.

References
[1] - http://wso2.com/products/enterprise-service-bus/
[2] - http://wso2.com/products/carbon/

NOTE: If you need to build any other Carbon based product, repeat the above steps by replacing the product name to the relevant product.

mvn version used for testing this was:

heshan@heshan-laptop:~$ mvn -version
Apache Maven 2.1.0 (r755702; 2009-03-19 00:40:27+0530)
Java version: 1.6.0_03
Java home: /home/heshan/Installations/jdk1.6.0_03/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" arch: "i386" Family: "unix"


Friday, May 28, 2010

Call MS SQL Server SPs from WSO2 ESB

This post will be focusing on MS SQL Server Stored Procedures(SP) and follow up my article titled "How to call database stored procedures from WSO2 ESB" on WSO2 OxygenTank.

You may think "why is he writing a separate post addressing MS SQL Server?". The reason is that; when calling MS SQL Server SPs, you need to slightly modify the mediator configuration in order to successfully call a SP.

Now let's dig in to "how to do this".

Setting up MS SQL database server
1. Install and setup MS SQL Server.

2. Create a sample database in MS SQL Server.
Following sql statments cab be used to create the same enviornment discussed in the above article.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[company]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[company](
[compName] [varchar](10) NULL,
[id] [varchar](10) NULL,
[price] [decimal](18, 0) NULL,
[location] [varchar](10) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[getCompany]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE procedure [dbo].[getCompany] @compname varchar(10) as
select * from company where compName = @compname
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[updateCompany]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE procedure [dbo].[updateCompany] @compPrice decimal, @compName varchar(10) as
update company set price = @compPrice where compName = @compName
'
END
Setting up ESB server
1. Download latest version of WSO2 ESB from http://wso2.org/downloads/esb. This tutorial will be demonstrated upon the latest release of the WSO2 ESB. ie. WSO2 ESB-3.0.0.

2. Install it as a standalone server. Install location will be referred to as ESB_HOME from here onwards.

3. When using MS SQL Server, ms-sql-jdbc.jar should be added to the ESB classpath(i.e. ESB_HOME/repository/components/lib/).

4. Start WSO2ESB using the startup scripts.
eg. wso2server.bat for windows environments
wso2server.sh for linux environments

5. Open a web browser and navigate to https://localhost:9443/

6. Login to ESB. The default username/password will be admin/admin. Go through the User Interface and get yourself familiarized with WSO2 ESB environment.

ESB configuration
Following is the Synapse configuration used to call the MS SQL Stored Procedure. Pay close attention on 'how the SP query is written inside the mediator' :).
<definitions xmlns="http://ws.apache.org/ns/synapse">

<sequence name="main">
<in>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</in>

<out>
<log level="custom">
<property name="text"
value="** Reporting to the Database **"/>
</log>

<dbreport>
<connection>
<pool>
<url>jdbc:sqlserver://10.100.1.200:1433;databaseName=ESB_SP_SAMPLE</url>
<user>sa</user>
<password>test</password>
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
</pool>
</connection>
<statement>
<sql>{ call updateCompany(?,?) }</sql>
<parameter expression="//m0:return/m1:last/child::text()"
xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd" type="DOUBLE"/>
<parameter expression="//m0:return/m1:symbol/child::text()"
xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd" type="VARCHAR"/>
</statement>
</dbreport>
<log level="custom">
<property name="text"
value="** Looking up from the Database **"/>
</log>
<dblookup>
<connection>
<pool>
<url>jdbc:sqlserver://10.100.1.200:1433;databaseName=ESB_SP_SAMPLE</url>
<user>sa</user>
<password>test</password>
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
</pool>
</connection>
<statement>
<sql>{ call getCompany(?) }</sql>
<parameter expression="//m0:return/m1:symbol/child::text()"
xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd" type="VARCHAR"/>
<result name="stock_prize" column="price"/>
</statement>
</dblookup>
<log level="custom">
<property name="text"
expression="fn:concat('Stock Prize - ',get-property('stock_prize'))"/>
</log>
<send/>
</out>
</sequence>

</definitions>
Running the sample.
1. Start the WSO2 ESB server with the attached synapse configuration named dbreport_synapse_config.xml.

2. Start the Axis2 server and deploy the SimpleStockQuoteService if not already done.

3. Run the client.
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=WSO2

Wednesday, May 19, 2010

SOA Summer School - 2010

Summer School will focus on Service Oriented Architecture (SOA) concepts, technologies, and best practices. In addition to that, this year's Summer School sessions will be including insights into proven techniques for cloud deployments, business process management (BPM), complex event processing (CEP) , business rules processing and more.

Summer School 2010 runs for two months starting 10th June and ending on 29th July. Do you know what's the best news about Summer School is ? IT'S ABSOLUTELY FREE ! :) yes, free as in open source ;)

If you are interested, you can register here.

Tuesday, May 11, 2010

Call database stored procedures from WSO2 ESB

Stored procedure is a powerful mechanism to interact with a relational database. It allows business logic to be embedded inside database as an API. Stored procedure is stored in a precompiled format within the database itself resulting in faster execution speed.

WSO2 Enterprise Service Bus is capable of calling database Stored Procedures via the db mediators. If your application uses stored procedures and you want to expose them to outside business systems, WSO2 ESB is the answer that you were looking for.

Read the full article on OT.

Sunday, May 2, 2010

The WSO2 Enterprise Service Bus (ESB) 3.0.0 Released

The WSO2 ESB team is pleased to announce the release of version 3.0.0 of the Open Source Enterprise Service Bus (ESB).

WSO2 ESB is a fast, lightweight and user friendly open source Enterprise Service Bus (ESB) distributed under the Apache Software License v2.0. WSO2 ESB allows system administrators and developers to easily configure message routing, intermediation, transformation, logging, task scheduling, fail over routing and load balancing. It also supports transport switching, eventing, rule based mediation and priority based mediation for advanced integration requirements. The ESB runtime is designed to be completely asynchronous, non-blocking and streaming based on the Apache Synapse mediation engine.

WSO2 ESB 3.0.0 is developed on top of the revolutionary WSO2 Carbon platform (Middleware a' la carte), an OSGi based framework that provides seamless modularity to your SOA via componentization. This release also contains many new features and a range of optional components (add-ons) that can be installed to customize the behavior of the ESB. Further, any existing features of the ESB which are not required to your environment can be easily removed using the underlying provisioning framework of Carbon. In brief, WSO2 ESB can be fully customized and tailored to meet your exact SOA needs.

You can download this distribution from http://wso2.org/downloads/esb and give it a try.

How to Run

  1. Extract the downloaded zip
  2. Go to the bin directory in the extracted folder
  3. Run the wso2server.sh or wso2server.bat as appropriate
  4. Point your browser to the URL https://localhost:9443/carbon
  5. Use "admin", "admin" as the username and password to login as an admin and create a user account
  6. Assign the required permissions to the user through a role
  7. If you need to start the OSGi console with the server use the property -DosgiConsole when starting the server. The INSTALL.txt file found on the installation directory will give you a comprehensive set of options and properties that can be passed into the startup script
  8. Sample configurations can be started by the wso2esb-samples script passing the sample number with the -sn option (Please have a look at the samples guide for more information, on running samples)

New Features of WSO2 ESB 3.0.0

  • Priority based mediation through priority executors
  • WS-Discovery support and dynamic endpoint discovery
  • Message Relay for efficient pass through of messages
  • Component manager to install and uninstall features (provisioning support)
  • Common Internet File System (CIFS) support through the VFS transport
  • File locking functionality in the VFS transport to support concurrent polling
  • Smooks mediator for efficient message transformation
  • Enrich mediator for smart message manipulation
  • OAuth mediator for 2-legged OAuth support
  • Default endpoint UI
  • Hot deploy and hot update configuration elements (sequences, endpoints, proxy services etc)
  • Transport level statistics collection and monitoring
  • POX security support
  • Dependency detection and alerting for mediation configuration elements
  • Mediation statistics API and custom mediation statistics consumers
  • Multiple certificate/identity support in the NHTTP transport sender
  • Improved logging capabilities for the NHTTP transport
  • Templates based proxy service development in the UI
  • Dashboard to monitor server environment and runtime
  • Easy creation and management capabilities for dynamic sequences and endpoints
  • Pagination to service management, endpoint management and sequence management UIs
  • Obtaining resources like WSDL's through web proxy servers

Key Features of WSO2 ESB

  • Proxy services - facilitating synchronous/asynchronous transport, interface (WSDL/Schema/Policy), message format (SOAP 1.1/1.2, POX/REST, Text, Binary), QoS (WS-Addressing/WS-Security/WS-RM) and optimization switching (MTOM/SwA).
  • Non-blocking HTTP/S transports based on Apache HttpCore-NIO for ultrafast execution and support for thousands of connections at high concurreny with constant memory usage.
  • Built in Registry/Repository, facilitating dynamic updating and reloading of the configuration and associated resources (e.g. XSLTs, XSD, WSDL, Policies, JS configurations ..)
  • Easily extendable via custom Java classes (mediator and command)/Spring configurations, or BSF Scripting languages (Javascript, Ruby, Groovy, etc.)
  • Built in support for scheduling tasks using the Quartz scheduler.
  • Load-balancing (with or without sticky sessions)/Fail-over, and clustered Throttling and Caching support
  • WS-Security, WS-Reliable Messaging, Caching & Throttling configurable via (message/operation/service level) WS-Policies
  • Lightweight, XML and Web services centric messaging model
  • Support for industrial standards (Hessian binary web service protocol/ Financial Information eXchange protocol and optional Health Level-7 protocol)
  • Enhanced support for the VFS (File/FTP/SFTP), JMS, Mail transports with optional TCP/UDP transports and transport switching among any of the above transports
  • Support for message splitting & aggregation using the EIP and service callouts
  • Database lookup & store support with DBMediators with reusable database connection pools
  • WS-Eventing support with event sources and event brokering
  • Rule based mediation of the messages using the Drools rule engine
  • Transactions support via the JMS transport and Transaction mediator for database mediators
  • Internationalized GUI management console with user management for configuration development
  • Integrated monitoring support with statistics, configurable logging and tracing
  • JMX monitoring support and JMX management capabilities like, Graceful/Forceful shutdown/restart

Bugs Fixed in This Release

This release of WSO2 ESB comes with a number of bug fixes, both in the base framework and the ESB specific componenents. All the issues which have been fixed in ESB 3.0.0 are recorded at following locations:

Known Issues

  • Endpoint UI does not support selecting already existing endpoints as child endpoints when creating load balance/failover endpoints
  • HTTP GET requests performed on an endpoint that has a trailing '/' character, do not work properly
  • SOAP tracer does not work when the message relay is activated
  • The sequence editor and the built-in XML editors do not work properly on Google Chrome

All the open issues pertaining to WSO2 ESB 3.0 are reported at following locations:

How You Can Contribute

Mailing Lists

Join our mailing list and correspond with the developers directly.

Reporting Issues

WSO2 encourages you to report issues and your enhancement requests for the WSO2 ESB using the public JIRA.

You can also watch how they are resolved, and comment on the progress..

Discussion Forums

Alternatively, questions could be raised using the forums available.

WSO2 ESB Forum : Discussion forum for WSO2 ESB developers/users

Support

We are committed to ensuring that your enterprise middleware deployment is completely supported from evaluation to production. Our unique approach ensures that all support leverages our open development methodology and is provided by the very same engineers who build the technology.

For more details and to take advantage of this unique opportunity please visit http://wso2.com/support.

For more information about WSO2 ESB please see http://wso2.com/products/enterprise-service-bus.

-- The WSO2 ESB Team --

Friday, April 30, 2010

Mediator to support Database stored procedure

Following blogpost shows how to use Apache Synapse's dblookup mediator to support a mysql database stored procedure.

Setting up mysql database server

1. Install mysql server.
heshan@heshan-laptop:~$ apt-get install mysql

2. Connect to mysql server.
heshan@heshan-laptop:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 300
Server version: 5.0.75-0ubuntu10.3 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

3. Create a sample databasae
mysql>CREATE DATABASE comp;

4. Create a table using the following statement.
mysql>CREATE TABLE company(name varchar(10), id varchar(10), price double);

5. Inserts some data using following statements
mysql>INSERT INTO company VALUES ('IBM','c1',3.7563);
mysql>INSERT INTO company VALUES ('SUN','c2',3.2554);
mysql>INSERT INTO company VALUES ('MSFT','c3',0.0);

6. Create a Stored Procedure.
mysql>CREATE PROCEDURE getCompany(compName VARCHAR(10)) SELECT name, id, price FROM company WHERE name = compName;

7.Add mysql-connector-java-5.1.12-bin.jar to the classpath. This can be done by putting the jar into the Synapse lib directory.

Running the Synapse sample
1. Save the following synapse-configuration as synapse_sample_364.xml to the samples folder.
SYNAPSE_HOME/repository/conf/sample/synapse_sample_364.xml

2. Synapse configuration.
<!-- SYNAPSE_HOME/repository/conf/sample/synapse_sample_364.xml -->
<definitions xmlns="http://synapse.apache.org/ns/2010/04/configuration">

<sequence name="myFaultHandler">
<makefault response="true">
<code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
<reason expression="get-property('ERROR_MESSAGE')"/>
</makefault>
<send/>
<drop/>
</sequence>

<sequence name="main" onError="myFaultHandler">
<in>
<log level="custom">
<property name="text"
value="** Looking up from the Database **"/>
</log>
<dblookup>
<connection>
<pool>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost/comp</url>
<user>root</user>
<password>admin</password>
</pool>
</connection>
<statement>
<sql>call getCompany(?)</sql>
<parameter expression="//m0:getQuote/m0:request/m0:symbol"
xmlns:m0="http://services.samples" type="VARCHAR"/>
<result name="company_id" column="id"/>
</statement>
</dblookup>

<switch source="get-property('company_id')">
<case regex="c1">
<log level="custom">
<property name="text"
expression="fn:concat('Company ID - ',get-property('company_id'))"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</case>
<case regex="c2">
<log level="custom">
<property name="text"
expression="fn:concat('Company ID - ',get-property('company_id'))"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</case>
<case regex="c3">
<log level="custom">
<property name="text"
expression="fn:concat('Company ID - ',get-property('company_id'))"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</case>
<default>
<log level="custom">
<property name="text" value="** Unrecognized Company ID **"/>
</log>
<makefault response="true">
<code value="tns:Receiver"
xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
<reason value="** Unrecognized Company ID **"/>
</makefault>
<send/>
<drop/>
</default>
</switch>
<drop/>
</in>

<out>
<send/>
</out>

</sequence>

</definitions>

3. Start the Synapse configuration numbered 364.
i.e. synapse -sample 364

4. Start the Axis2 server and deploy the SimpleStockQuoteService if not already done.

5. Run the client.
ant stockquote -Daddurl=http://localhost:9000/soap/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=IBM 

6. Voila, you have invoked a database stored procedure.

Tuesday, April 27, 2010

Running Synapse ESB's Script Mediator with include option

Apache Synapse ESB's Script Mediator can be used for message mediation. Sample 350 of Synapse samples is demonstrating how this Script Mediator can be used in a real world scenario.

Suppose the script you specified is calling a function of another script. Then the latter script should also be included in the script mediator configuration. It's done using the <include> element. The key attribute of the <include> element can be specified with the script program statements stored in a separate file, which is referenced via the local or remote registry entry. Following example shows how it can be done.
<script key="string" language="string" [function="script-function-name"]>
<include key="string"/>
</script>
I am using the same example used in Sample 350 to demonstrate this scenario.

1) Replace the stockquoteTransform.js with the following javascript.

// stockquoteTransform.js
function transformRequest(mc) {
transformRequestFunction(mc);
}

function transformResponse(mc) {
transformResponseFunction(mc);
}

2) Add the following sample.js file to SYNAPSE_HOME/repository/samples/resources/script

// sample.js
function transformRequestFunction(mc) {
var symbol = mc.getPayloadXML()..*::Code.toString();
mc.setPayloadXML(
<m:getquote m="http://services.samples">
<m:request>
<m:symbol>{symbol}</m:symbol>
</m:request>
</m:getquote>);
}

function transformResponse(mc) {
var symbol = mc.getPayloadXML()..*::symbol.toString();
var price = mc.getPayloadXML()..*::last.toString();
mc.setPayloadXML(
<m:checkpriceresponse m="http://services.samples/xsd">
<m:code>{symbol}</m:code>
<m:price>{price}</m:price>
</m:checkpriceresponse>);
}

3) Update the synapse configuration with the following configuration.

<definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="stockquoteScript" src="file:repository/conf/sample/resources/script/stockquoteTransform.js"/>
<localEntry key="sampleScript" src="file:repository/samples/resources/script/sample.js"/>

<in>
<!-- transform the custom quote request into a standard quote request expected by the service -->
<script language="js" key="stockquoteScript" function="transformRequest">
<include key="sampleScript"/>
<script>
<send>
<endpoint>
<address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
</endpoint>
</send>
</in>
<out>
<!-- transform the standard response back into the custom format the client expects -->
<script language="js" key="stockquoteScript" function="transformResponse"/>
<include key="sampleScript"/>
<script>
<send/>
</out>
</definitions>

4) Start the Synapse ESB with the above configuration. Deploy the SimpleStockQuote service (which is shipped with Synapse) on SimpleAxisServer. Then invoke the client giving the following command.

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=customquote

5) It will yield the following result.
   [java] Custom :: Stock price = $161.76045110619708 

6) For more information.
WSO2 ESB articles - http://wso2.org/library/esb
Apache Synapse - http://synapse.apache.org/

Monday, April 5, 2010

Recursively remove .svn files

Following command can be used to recursively remove .svn files.

Following command can be used to list out .svn files.

find . -type d -name .svn

Following command can be used to remove all .svn files.
 
rm -rf `find . -type d -name .svn`

Friday, April 2, 2010

Using Event Broker in WSO2 Carbon to generate Events

Following code/configuration show what are required to make use of the event broker in carbon to generate events. In the following example we are looking at how to generate an email notification.

1). Declarative Service Component to obtain the service URL.

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.ListenerManager;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.AxisFault;
import org.apache.log4j.*;
import org.osgi.service.component.ComponentContext;
import org.osgi.framework.BundleContext;
import org.wso2.carbon.utils.ConfigurationContextService;
import org.wso2.carbon.utils.NetworkUtils;
import org.wso2.carbon.eventing.broker.services.EventBrokerService;

import java.net.SocketException;

/**
* @scr.component name="org.wso2.carbon.health.service" immediate="true"
* @scr.reference name="configuration.context.service"
* interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1"
* policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
* @scr.reference name="listener.manager.service"
* interface="org.apache.axis2.engine.ListenerManager" cardinality="0..1" policy="dynamic"
* bind="setListenerManager" unbind="unsetListenerManager"
* @scr.reference name="eventbroker.service"
* interface="org.wso2.carbon.eventing.broker.services.EventBrokerService"
* cardinality="1..1" policy="dynamic" target="(name=HealthMonitorEventBroker)"
* bind="setHealthMonitorEventBrokerService" unbind="unsetHealthMonitorEventBrokerService"
*/
public class HealthMonitorEventingServiceComponent {
private static Log log = LogFactory.getLog(HealthMonitorEventingServiceComponent.class);

private boolean configurationDone = false;

private ConfigurationContextService configurationContextService = null;

private ListenerManager listenerManager = null;

private boolean initialized = false;

private static EventBrokerService healthMonitorEventBrokerService = null;

private String endpoint = null;

private static BundleContext bundleContext = null;

static Logger logger = Logger.getLogger(HealthMonitorEventingServiceComponent.class);

Logger rootLogger = LogManager.getRootLogger();

protected void activate(ComponentContext context) {
bundleContext = context.getBundleContext();
}

public static BundleContext getBundleContext() {
return bundleContext;
}

private void initializeAppender() {
if (listenerManager == null || healthMonitorEventBrokerService == null) {
return;
}
System.out.println("Carbon Health Monitor started!");

rootLogger.addAppender(new JiraAppender());
log.info("Jira appender added to the root logger");
// Setting level of root logger
//rootLogger.setLevel(Level.DEBUG);

addAppenders();
rootLogger.error("This log message is used to trigger the JiraAppender");
}

public void addAppenders() {
SimpleLayout layout = new SimpleLayout();
FileAppender appender = null;
try {
appender = new FileAppender(layout, "/tmp/output1.txt", false);
} catch (Exception e) {
logger.error(e);
}

rootLogger.addAppender(appender);
logger.debug("DEBUG message 2");
logger.debug("DEBUG message 3");
log.info("Appender added to the logger");
}

protected void deactivate(ComponentContext context) {
}

protected void setConfigurationContextService(ConfigurationContextService configurationContextService) {
this.configurationContextService = configurationContextService;
}

protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) {
}

protected void setHealthMonitorEventBrokerService(EventBrokerService healthMonitorEventBrokerService) {
this.healthMonitorEventBrokerService = healthMonitorEventBrokerService;
initializeAppender();
}

protected void unsetHealthMonitorEventBrokerService(EventBrokerService healthMonitorEventBrokerService) {
this.healthMonitorEventBrokerService = null;
}

protected void setListenerManager(ListenerManager listenerManager) {
this.listenerManager = listenerManager;
initialize();
initializeAppender();
}

protected void unsetListenerManager(ListenerManager listenerManager) {
this.listenerManager = null;
}

private void initialize() {
ConfigurationContext serverConfigurationContext = configurationContextService.getServerConfigContext();
if (!configurationDone && listenerManager != null) {
String host = null;
try {
host = NetworkUtils.getLocalHostname();
} catch (SocketException e) { }
if (serverConfigurationContext != null) {
AxisConfiguration config = serverConfigurationContext.getAxisConfiguration();
if (config != null && config.getTransportIn("http") != null &&
config.getTransportIn("http").getReceiver() != null) {
try {
EndpointReference[] eprArray = config.getTransportIn("http")
.getReceiver().getEPRsForService("HealthMonitorEventingService",
host);
if (eprArray != null && eprArray[0] != null) {
endpoint = eprArray[0].getAddress();
}
} catch (AxisFault e) { }
}
}
configurationDone = true;
}
}

public static EventBrokerService getHealthMonitorEventBrokerService() {
return healthMonitorEventBrokerService;
}
}


2). Generating Events.

OMFactory fac = OMAbstractFactory.getOMFactory();
Event<OMElement> event = new Event<OMElement>(zipElement);
event.setTopic("/mail-sending/mail");
OMElement topic = EventBrokerUtils.buildTopic(fac,event);
EventBrokerUtils.generateEvent(event.getMessage(), topic, HealthMonitorEventingServiceComponent.getHealthMonitorEventBrokerService());


3). The services.xml for the service.

<serviceGroup>
<service name="HealthMonitorEventingService" targetNamespace="http://eventing.registry.carbon.wso2.org">
<transports>
<transport>http</transport>
</transports>
<description>
Health Monitor Eventing Service
</description>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.wso2.carbon.eventing.broker.receivers.CarbonEventingMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.wso2.carbon.eventing.broker.receivers.CarbonEventingMessageReceiver"/>
</messageReceivers>
<parameter name="enableSubscribe" locked="true">true</parameter>
<operation name="Subscribe" mep="http://www.w3.org/ns/wsdl/in-out">
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</actionMapping>
</operation>
<parameter name="enableRenew" locked="true">false</parameter>
<!--operation name="Renew" mep="http://www.w3.org/ns/wsdl/in-out">
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew</actionMapping>
</operation-->
<parameter name="enableUnsubscribe" locked="true">false</parameter>
<!--operation name="Unsubscribe" mep="http://www.w3.org/ns/wsdl/in-out">
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</actionMapping>
</operation-->
<parameter name="enableGetStatus" locked="true">false</parameter>
<!--operation name="GetStatus" mep="http://www.w3.org/ns/wsdl/in-out">
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus</actionMapping>
</operation-->
<operation name="Publish" mep="http://www.w3.org/ns/wsdl/in-out">
<actionMapping>http://ws.apache.org/ws/2007/05/eventing-extended/Publish</actionMapping>
</operation>

<parameter name="eventBrokerInstance" locked="true">HealthMonitorEventBroker</parameter>
</service>
<parameter name="hiddenService" locked="true">true</parameter>
</serviceGroup>


4). Event Broker configuration

<eventBroker xmlns="http://wso2.org/ns/2009/09/eventing">
<eventStream name="HealthMonitorEventBroker">
<subscriptionManager class="org.wso2.carbon.eventing.impl.EmbeddedRegistryBasedSubscriptionManager">
<parameter name="topicHeaderName">topic</parameter>
<parameter name="topicHeaderNS">http://wso2.org/ns/2009/09/eventing/notify</parameter>
<parameter name="subscriptionStoragePath">/carbon/eventing/registry</parameter>
</subscriptionManager>
<!-- Uncomment to to RemoteRegistryBasedSubscriptionManager -->
<!--subscriptionManager class="org.wso2.carbon.eventing.impl.RemoteRegistryBasedSubscriptionManager">
<parameter name="topicHeaderName">topic</parameter>
<parameter name="topicHeaderNS">http://wso2.org/ns/2009/09/eventing/notify</parameter>
<parameter name="subscriptionStoragePath">/carbon/eventing/registry</parameter>
<parameter name="registryURL">http://remote-ip:port/registry/</parameter>
<parameter name="username">username</parameter>
<parameter name="password">password</parameter>
</subscriptionManager-->
<!--<eventDispatcher>org.wso2.carbon.registry.eventing.RegistryEventDispatcher</eventDispatcher>-->
<eventDispatcher>org.wso2.carbon.eventing.broker.CarbonEventDispatcher</eventDispatcher>
<notificationManager class="org.wso2.carbon.eventing.broker.CarbonNotificationManager">
<parameter name="minSpareThreads">25</parameter>
<parameter name="maxThreads">150</parameter>
<parameter name="maxQueuedRequests">100</parameter>
<!-- Keep Alive time in nano seconds -->
<parameter name="keepAliveTime">1000</parameter>
<!-- Specify path of security policy file to enable security. -->
<!--parameter name="securityPolicy">policypath</parameter-->

<!-- Parameters specific to the Registry Event Broker configuration -->
<!-- Set this as false to disable displaying of registry URL in notification e-mails -->
<parameter name="showRegistryURL" locked="true">true</parameter>
</notificationManager>
</eventStream>
</eventBroker>


I have used the above method to generate email notifications within the Carbon Health Monitor component which I developed. More info on Health Monitor component will be discussed later.