The simplest way to start using ServiceMix to wire together JBI components is via Spring and the XML configuration file mechanism from Spring.

Why use Spring?

Using Spring has quite a few benefits to using the traditional JBI deployment units and configuration file mechanism

It's also worth pointing out that a single component can be used in a Spring configuration or in a traditional JBI deployment unit without any code changes so you are free to choose either approach.

The only downsides of using Spring are

Configuring using Spring XML

So let's see how to wire together a couple of components with Spring. The easiest way to get started is to see an example. The following configuration is taken from these examples.

{snippet:id=example|lang=xml|url=servicemix/smx3/trunk/common/servicemix-components/src/test/resources/org/apache/servicemix/components/pojo/example.xml}

 

We introduce a few new XML tags for JBI configuration, but apart from that you can use all of the regular Spring configuration tags - bean, property, value etc. For example, inside the <container> tag you can configure properties on the JBI container itself using <property> tags. Inside each <component> tag you can configure properties on the component. This allows you to mix and match regular Spring configuration of POJOs with our JBI Spring configuration mechanism.

Routing services together.

As you can see in the above example we use destinationService or destinationInterface or destinationOpertion on a <component> to denote its routing. A component can decide if it wishes how to route requests to another service. If the component just routes to the default output service then these destination settings are used by ServiceMix to route the request.

Using pure Spring

If you don't wish to use the Spring extension XML as shown above you can configure ServiceMix and its components using regular Spring XML. Here's how

Here is an example of that in action.

Related Documentation

The following tutorial shows how to create JBI components using the Spring Client Toolkit.