Thursday, January 22, 2009

Its time to Stop Forwarding junk mails

With the fast growth of internet facilities and lot of free space given in mail accounts.Now People used to forward some mails that contain

Wishes , Beautiful Pictures ,etc....
They are using it as a good way of keeping touch with friends.

But if we see the size of those mails with attachments.and the way they are transfered between people its a great waste of resources.each and every mail we send use the processing power of every node in its path.Processing time of those nodes means power.

I think its time for us to sit back and think about the big process happening behind before we forward a another mail.

according to the Butterfly effect "Small variations of the initial condition of a dynamical system may produce large variations in the long term behavior of the system."

Lets make that Small variation for the betterment of the globe.
So lets try do minimize the unwanted data transfers through networks.And save some resources of the globe.

As a conclusion i remember a great saying "Earth has more than enough resources to fulfill mans needs but not his unlimited desires"

Tuesday, January 6, 2009

Apache Synapse Spring Mediator -(Feel the power of Apache Synapse)

Apache Synapse is a Light weight ESB from Apache which supports XML webservies. And also it is a very extendible project[1].

Massage mediation is a core mode in Synapse. When in massage mediation mode Synapse act as a transparent proxy for clients. And also if Synapse receives a massage that does not belongs to any of the proxy services it will go through massage mediation[2] defined.

Synapse has Components named as Mediators witch can perform mediation action on the Message(MessageContext).Mediators get the full control over the message that is passing through it. Mediator can modify and inspect message or do something by looking at the message body. Since Synapse supports writing custom mediators the possibilities of usage of Mediators become unlimited.

Synapse Spring Mediator is a Mediator which enables Spring users to expose their Spring Beans as Mediators in Synapse.

Following is a example of how to use Spring Mediator

First thing we have to do is write a simple Bean that extends org.apache.synapse.mediators.AbstractMediator (AbstractMediator class can be found in Synapse core).


package demo.hello;

import .....

public class HelloMediator extends AbstractMediator {

private String name;

public void setName(String name){;


public String getName(){

return name;


public boolean mediate(MessageContext synCtx) {

System.out.println(“Messsage Id: ”+ synCtx.getMessageID());

System.out.println(“Hello ”+name);

return true;



then put that class in to a Jar file and put it in the lib directory in Synapse installation directory(SYNAPSE_HOME).

Then we should write a xml file for that Spring Bean

ex: springsample.xml

and then we must write a SynapseConfiguration to use this. For that edit the Synapse.xml file in SYNAPSE_HOME/repository/conf/ as follows

put the springsample.xml in repository/conf/ directory of the Synapse installation directory.

Then Start the Synapse and try sending a message through synapse (you can use the client and server that is used in Synapse sample 0).

Above example shows how we can use the Synapse Spring Mediator to make Spring Bean a Mediator.

Now lets Look at the Power of this usage of Spring mediator. Since a mediator gives the total control over the message passing through it and the Spring supports Inject dependencies to the Spring bean using a XML configuration file,using a Spring Bean as a Mediator gives Spring users unlimited degree of freedom over the Message passing through the Spring bean.

One possibility came across my mind is Spring Users can use the Spring Mediator as a Bridge to pass a the Message to their own project.Using the inversion of control capability given by Spring .Spring users can make that very effective and flexible.

As image shows Spring Bean Mediator can be used as a bridge to pass the Messsage context to a project,And using the Spring XML file user can define appropriate dependencies that can be used to process the message without changing the code or changing Synapse Configuration. The main advantage here is Spring users do not have to have the knowledge on Synapse configuration. Once they have configure the synapse to use the the Spring Mediator they can use and change the Spring XML file to inject dependencies that can be used to use/change the message context.

And also I think Spring Mediator can be used to make a Wrapper Software project around synapse(As the same way synapse is wrapped around axis2) and Spring XML file can be used as a configuration file for that software.

[1] -