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 ...

No comments: