Thursday, March 08, 2007

Performances of ServiceMix WSDL-First example

I have spent some time profiling ServiceMix a bit, and particularly the WSDL-First example from the distribution. Here are the results while running a SOAP UI load tests on the example from the 3.1 distribution and the upcoming 3.1.1 distribution:

Version, min, max, avg, last, cnt, tps, bytes, bps, err
SMX 3.1, 9, 234, 20.64, 14, 57724, 484.43, 19106644, 159450, 0
SMX 3.1.1, 5, 204, 16.75, 14, 71065, 596.99, 23522515, 196095, 0

The most interesting number is the tps (transaction per seconds) absolute number: roughly 600 transactions per seconds sounds like a reasonable number (this small tests were running on my laptop without any particular tuning on the JVM or ServiceMix configuration) !

The other one is the tpc increase between 3.1 and 3.1.1:

595.99 / 484.43 = 1.2324

which means this sample performances for this sample has been boosted by 23 percents !

Wednesday, March 07, 2007

Using maven to switch runtime properties

For those who don't know all of Maven's features, I will show how to leverage maven at built-time to easily share run-time properties between service units in ServiceMix.

Let's say that you expose a few services over HTTP/SOAP using servicemix-http. If you are building several service assemblies, you will end up having several files containing:

<http:endpoint service="test:MyConsumerService"
soapVersion="1.1" />

You will certainly want all your services to be exposed on the same port, so it can become a bit tedious if you need to change them all, or if you need to change between different work environments (test, production, etc...).

When working with several service assemblies at the same time, I would recommend to use a hierachical organization for your maven projects:

|- module1
| |- module1-http-su
| |- module1-jsr181-su
| \- module1-sa
|- module2
| |- module2-http-su
| |- module2-jsr181-su
| \- module2-sa

This has several advantages: aside from organizing your code logically, you can use mvn jbi:projectDeploy at the root level, or at a sub-level.

So, now, how can we use maven for our properties ? Well, we just have to create them in the root pom:


Then, we need to enable maven resource filtering in our root pom:


And of course, we need to use them. So instead of the previous xbean.xml, we can now use:

<http:endpoint service="test:MyConsumerService"
soapVersion="${deployment-soap-version}" />

So now, if you want to switch your port, just change the root pom property and rebuild :-)

The next step is to use maven profiles to define environment and easily switch between those. This is maybe not useful for changing the HTTP port use, but if you configure some database access, you can easily switch between your production database and an embedded one for testing ...

Monday, March 05, 2007

ServiceMix dependencies

I have just fixed a small bug in ServiceMix (SM-865) and this makes ServiceMix a *very* lightweight ESB. The bare minimum dependencies to run the following example are:
  • servicemix-core
  • servicemix-jbi
  • servicemix-services
  • backport-util-concurrent
  • spring
  • xbean-spring

The example I ran is very simple, and of course dependencies need to be added depending on the JBI components you use. Anyway, here is the servicemix.xml file:

<beans xmlns:sm=""
<sm:container id="jbi" embedded="true">
<sm:activationSpec service="test:echo">
<bean class="org.apache.servicemix.components.util.EchoComponent" />
<sm:client id="client" container="#jbi" />

And here is the java code used:

import javax.jbi.messaging.InOut;
import javax.xml.namespace.QName;
import org.apache.servicemix.client.ServiceMixClient;
import org.apache.servicemix.jbi.jaxp.StringSource;
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.context.ApplicationContext;

public class Main {
public static void main(String[] args) throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("servicemix.xml");
ServiceMixClient client = (ServiceMixClient) context.getBean("client");
InOut me = client.createInOutExchange();
me.setService(new QName("urn:test", "echo"));
me.getInMessage().setContent(new StringSource("world"));

This is the results of the work that has been done for the 3.1 release. The next step is to use the standard JBI components from ServiceMix ...