Thursday, October 25, 2012

How to increase the external invocation timeout for a BPEL process in BPS

There are situations where we need to invoke a service which will take quite sometime to respond within a bpel invoke. In such a scenario, you can use following settings to increase the default timeout values.

Increase the default values for MessageExchange timeout and External service invocation timeout. Also set the SO_TIMEOUT parameter and CONNECTION_TIMEOUT parameter in HttpSender.

Here, we are increasing the timeout value from default value to 10 minutes.

bps.xml
 

<tns:MexTimeOut value="600000"/>
<tns:ExternalServiceTimeOut value="600000"/>


axis2.xml

<transportSender name="http"
                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
        <parameter name="PROTOCOL">HTTP/1.1</parameter>
        <parameter name="Transfer-Encoding">chunked</parameter>
        <!-- This parameter has been added to overcome problems encounted in SOAP action parameter -->
        <parameter name="OmitSOAP12Action">true</parameter>
        <parameter name="SO_TIMEOUT">600000</parameter>
        <parameter name="CONNECTION_TIMEOUT">600000</parameter>
    </transportSender>
    

Tuesday, October 16, 2012

How to invoke Admin Services with SoapUI

It is very very easy to invoke WSO2 Carbon Admin Services with SOAP UI.

Step 1. 
Use the AuthenticationAdmin Service to obtain the session cookie.
You can access the AuthenticationAdmin WSDL of a carbon server with the following url assuming that the server is running with default ports.

http://localhost:9763/services/AuthenticationAdmin?wsdl

SOAP SoapUI to generate the Client for it.
Now invoke the login method. A sample request would be like



<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:aut="http://authentication.services.core.carbon.wso2.org">
   <soap:Header/>
   <soap:Body>
      <aut:login>
         <!--Optional:-->
         <aut:username>admin</aut:username>
         <!--Optional:-->
         <aut:password>admin</aut:password>
         <!--Optional:-->
         <aut:remoteAddress>127.0.0.1</aut:remoteAddress>
      </aut:login>
   </soap:Body>
</soap:Envelope>


In the response message, an HTTP Header will be available with a session cookie.

HTTP/1.1 200 OK

Set-Cookie: JSESSIONID=2671C3A974C0FE67BD9D1DDF665E1DC3; Path=/; Secure; HttpOnly
Content-Type: application/soap+xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 16 Oct 2012 18:48:33 GMT
Server: WSO2 Carbon Server

Step 2.

Now when invoking any other admin service, add the http header COOKIE from soap UI.

COOKIE: JSESSIONID=2671C3A974C0FE67BD9D1DDF665E1DC3
A sample request message would look like 

POST http://localhost:9763/services/ProcessManagementService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:getProcessInfo"
COOKIE: JSESSIONID=2671C3A974C0FE67BD9D1DDF665E1DC3
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:9763
Content-Length: 571

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>local://services/ProcessManagementService</wsa:To>
<wsa:MessageID>urn:uuid:ac59f8ff-de2e-42d1-88f6-2542d54a869c</wsa:MessageID>
<wsa:Action>urn:getProcessInfo</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<ns1:getProcessInfoIn xmlns:ns1="http://wso2.org/bps/management/schema">
<ns1:pid xmlns:s13="http://ode/bpel/unit-test">s13:HelloWorld2-2</ns1:pid>
</ns1:getProcessInfoIn>
</soapenv:Body>
</soapenv:Envelope>



Sunday, October 14, 2012

Installing WSO2 BPS on PostgreSQL

BPS requires two database schema's. One is for the registry and one for BPEL, Human Task engine. So we will need to create two database schema's on postgresql and grant permissions. Lets name the registry database as bpsRegistry and orchestration engine database as bps.
Step 1.
Install postgresql.
$ sudo apt-get install postgresql
Step 2.
Configure postgresql 
Edit postgresql.conf file located in /etc/postgresql/9.1/main directory and un-comment the following line
listen_addresses = 'localhost'

Step 3.
When postgres sql is installed, a user named postgres will be created. We need to login as this user in order to create our databases, add our default role to postgres and grant privileges.First login as root and then  change user to postgres user.
$ sudo su
$ su postgres

Step 4
Connect to the database and configure roles.
$ psql template1
Add default user to postgres.
template1=# CREATE USER nandika WITH PASSWORD 'password';

Step 5
Create the two databases.
template1=# CREATE DATABASE bps;
template1=# CREATE DATABASE bpsRegistry;
Now grant all privileges to database.
template1=# GRANT ALL PRIVILEGES ON DATABASE bps to nandika;
template1=# GRANT ALL PRIVILEGES ON DATABASE bpsRegistry to nandika;
you can use \q to quit.
Step 6.

Now, test the databases and run the db scripts found in wso2bps-3.0.0/dbscripts directory to create the db tables.
$ psql -d bpsregistry -U nandika;
bpsRegistry=>

Now run the postgresql.sql script to create the tables.
bpsRegistry=> \i /home/nandika/wso2bps-3.0.0/dbscripts/postgresql.sql
This should execute the sql script and create the database tables. 
Similarly, execute the postgres.sql in dbscripts/bps directory to create the bps database tables.

Note : you can use \? to view the available postgres sql commands.
Now we are done with configuring postgres sql. Lets configure bps db connection urls.
Step 7.

Go to repository/conf/datasources directory and edit master-datasources.xml and replace the existing H2 database configurations with corresponding postgresql configuration.
 
        <datasource>
            <name>BPSREG_DB</name>
            <description>The datasource used for registry</description>
            <jndiConfig>
                <name>jdbc/BPSRegDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:postgresql://localhost/bpsregistry</url>
                    <username>nandika</username>
                    <password>password</password>
                    <driverClassName>org.postgresql.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>
            
Next , open the datasources.properties file in repository/conf directory and all following.
synapse.datasources.bpsds.registry=JNDI
synapse.datasources.bpsds.type=BasicDataSource
synapse.datasources.bpsds.driverClassName=org.postgresql.Driver
synapse.datasources.bpsds.url=jdbc:postgresql://127.0.0.1:5432/bps?user=nandika&password=password
synapse.datasources.bpsds.username=nandika
synapse.datasources.bpsds.password=password
synapse.datasources.bpsds.validationQuery=SELECT 1
synapse.datasources.bpsds.dsName=bpsds
synapse.datasources.bpsds.maxActive=100
synapse.datasources.bpsds.maxIdle=20
synapse.datasources.bpsds.maxWait=10000

Next, download and copy postgres sql driver to repository/components/lib directory. Now we have finished configurations. Go to bin directory and run wso2server.sh to start BPS.

Open Source and Your Career

I consider that the golden rule requires that if I like a program , I must share it with other people.  - Richard Stallman

Open Source
Open source is a philosophy that promotes free distribution of technical information. (A products design and implementation details) The concept has been there long before the open source movements took it and popularized it. The above comment from Richard Stallman (The founder of free software foundation) explains the philosophy behind open source. The golden rule or the rule of reciprocity essentially states the following. One should treat others as one would like others to treat oneself”. When this rule is applied to software world, it is all about sharing the knowledge, code and skills such that we all can collectively benefit from it.

Career
The difference between a job and a career is the difference between forty and sixty hours a week – Robert Frost
            A career is a chosen life goals or chosen field of expertise. To become a successful career person one has to acquire special skills from learning and training and it also requires lot of dedication and hard work to succeed.
            A job is done for the sole purpose of earning money. Jobs are performed over a fixed period time. Usually a person who is doing a job would turn up for the office in the morning; follow some routine tasks and would leave in the evening often without regard to the completion of the tasks. A career person on the other hand would consider work as an extension of himself. Often a person’s lifetime of achievements is tied to his career.
            Being an IT person means being a career person. The technologies in the industry is constantly evolving and changing and hence it requires constant learning in order to survive and succeed in the IT industry. Also all IT projects requires lot of dedication from the people involved in order to succeed. Any person who has done a product release would know how many long hours were required to get the product out.

Now having looked into the open source philosophy and what a career means, let us look at how one can benefit from open source development movement to succeed in an IT career.

Open source software is no longer a small time geek thing. There is worldwide adoption of open source software in many industries and its market share is continuing to increase.

1. There has been a huge change of direction in software adoption after the recession at the end of last decade. Most companies had to look at ways to cut down the costs in order to survive and this led CIO’s look for cheaper options of software. By adopting open source software, companies have to incur only a fraction of the cost of commercial software.

2. Open source software products are now available for wide variety of purposes and most of these products have been around and have matured enough for industrial deployment.

3. There is always some company behind an open source project and in some cases, there are many companies and hence the availability of enterprise class support. For example Linux kernel is developed in participation of large number of companies including the likes of IBM, HP, Red hat etc.

Many people come to think of open source software is developed by geek/hacker/academics programmers in their spare time. Although there is much such software, this is not the case with many mainstream open source projects. For example, following table shows the Linux kernel contribution data.



                                                Linux Kernel data ( Table )
As you can see, there are hundreds of companies behind Linux kernel and they had contributed thousands of developers to Linux kernel. This is a clear example of the amount of career opportunities that exist in the open source software industry.

Why participate in an open source project

Why would someone dedicate his time and skills to participate in an open source project? Well, there are many reasons. Advancing the state of the art in computing, to become part of a team that create great software, work with some highly talented people, being truly creative are some of the motivations behind participating in an open source project. Of course there is nothing like doing something useful and beneficial to others while learning and having fun.

What you gain
Being part of an open source project can benefit you as a student, as an IT professional in many ways.
1. Communication Skills
           Software projects need excellent communication throughout the development cycle to succeed. However, there is always lack of people who explain technical detail in a precise manner.  Open source participation is a great way to develop  written communication skills because , that is the only way you can participate effectively as the code is developed by individuals who are geographically dispersed, and communicated primarily using email.    

2. Programming Skills
Programming is a skill that is mastered by practice. Trying to read and understand good quality code is a great way to pick up coding technique and style.

3. Technical expertise and research skills
            Open source requires lot of self-learning and research due to the very nature of development style. Long term participant of an open source project can develop exceptional research skills and technical expertise that is par with the best in the world.

4. Networking
Open source development is a great way to get to know people from the industry around the world. Not only does it help you get to know some of the best minds but also you may be able to develop friendships across the globe.

5. Experience the entire software engineering lifecycle
            Software product development process consist of many parts including inception, developing code, testing, packaging , releasing , writing documentation , providing support, and maintenance.
            An engineer in a normal software company would only participate in few phases of the above process. For example a developer might participate in the development phase. A QA engineer would participate in the QA phase.
            However, in an open source project, this is entirely different. The core committer team would participate in all the phases of the product life cycle. They would be the developers, testers, release managers, support provides and bug fixes. Also they would be doing a lot of marketing activities such as blogging, presentations in the conferences etc. Hence a programmer in an open source project can develop excellent skills over time.

6. Reputation
            Unlike most developers in commercial software companies, a programmer in an open source project can claim his work and develop a reputation for himself.

7. Higher Studies.
            When students apply for higher studies overseas, the evaluators will be looking for factors to identify exceptional people. As such GPA, GRE etc. does not mean a lot as these are common to all students. However, a student programmer how has open source credentials has a distinct advantage.

8. Employment
            Some open source products have become industry standards for doing tasks. For example, svn and git are widely used as version control systems. Similarly, maven, ant are the standard build tools for many java projects. Therefore having skills in these products can be a great benefit in the jobs. Also, a programmer with open source credentials can easily land a job because, his skills are already proven and his work is out there in the open for all to see.
           
9. Your own business
            You can build your own company around open source software consultancy or product development. For example, by mastering php, drupal, joomla, wordpress etc., one can easily build a successful web development company.

Participating in open source.
            To become a valued open source contributor, you need two essential things.
1. Motivation.
            Open source is not an instant reward thing for a developer. It takes time and effort to become a valued member. Hence a programmer needs lots of motivation to keep going.     

2. Self-Learning
Of course you have to be a very good self-learner.














Join a project.

There are hundreds of great open source projects out there and there is great deal of opportunity waiting for you. You can contribute to an open source project in multiple ways.

User

Every project needs some developers, but also, they need many users. You can easily contribute by becoming an active user of an open source project. All you have to do is to download and use the product for your work. When you encounter problems, go to the product forums, mailing lists and ask questions. When you hit bugs, go to the project bug tracking system and report them. That way, not only you are benefiting but also making a contribution to the project as well. Also make sure to write blogs on how you use the product. Include your code samples as well. Many open source projects lack through documentation and hence your blog post could help many fellow developers out there.

Contributor

A contributor would be a person who dig deeper into the code and fix bugs and provide patches. As a contributor, one can give new ideas to discussions, contribute additions and extensions and help in testing and documentation. Contributor is only a step away from becoming a committer.

Committer
  committer in an open source project is a programmer who commits to the source code repository. A committer's contribution consist of writing code, bug fixes, documentation additions, introduce new ideas and implement them and also participate in testing and release processes. To become a committer of an open source project, you have to demonstrate not only your technical skills but also your commitment to the project in the long term.

Your own open source project
Open source is about reuse. When Linus Torvalds started writing Linux, he did not do it from scratch. He started from Minix operating system and systematically improved it piece by piece to what finally became Linux.  Therefore, if you find some product can be improved or done in a better why, you can start your own project and develop it in a systematic way. If you have code that can be useful to others, always contribute it.  You might have some grate ideas that would change the world.

I’ve found that luck is quite predictable. If you want more luck, take more chances. —Brian Tracy

How to succeed in open source

Publish your code.
If you start your own project, there are many sites that let you host your code. Github, sourceforge and google code are some them. If you make improvements to an existing project, make sure to contribute your changes back to the project.

Show your work.
Of course, being open source means, you can claim your contributions. For example, by configuring your project with ohloh.com, you can show your contribution.

Write
Writing is an essential part of being an open source programmer. You have to do your own marketing for the project. Blogging is an important part of that. Most open source foundations have their blog roll which is known as planets. Planet Apache and Planet PHP are two such examples. You can submit your blog to these blog rolls and greatly increase your visitor count. Writing articles to popular web sites is another important aspect of marketing your work. Not only you can contribute with it, but also you can earn some extra money in the process.

Success.
Let me tell you the secret that led me to my goal. My strength lies solely in my tenacity - Louis Pasteur

When we talk about success in any task, we usually take about passion, commitment, and dedication. Even though those qualities are important, when it comes to success, the single most important quality is the tenacity. That never give up attitude, that special thing that keeps you going till the end no matter what obstacles you have to face, is what matters the most.

[ My speech at Apache Meetup , Kandy ]