Before we show how to configure ServiceMix 4.0 for use, let us first look at the architecture of ServiceMix 4.0. This figure shows the following components:
![Architecture of ServiceMix](../../../../../../../../../../../Downloads/_refcardz_html/images/rc065-010d-servicemix/rc065-010d-servicemix-1.jpg)
ServiceMix Kernel: In this figure you can see that the basis of ServiceMix 4 is the ServiceMix Kernel. This kernel, which is based on the Apache Felix Karaf project (an OSGi based runtime), handles the core features ServiceMix provides, such as hot-deployment, provisioning of libraries or applications, remote access using ssh, JMX management and more.
ServiceMix NMR: This component, a normalized message router, handles all the routing of messages within ServiceMix and is used by all the other components.
>ActiveMQ: ActiveMQ, another Apache project, is the message broker which is used to exchange messages between components. Besides this ActiveMQ can also be used to create a fully distributed ESB.
Web: ServiceMix 4 also provides a web component. You can use this to start ServiceMix 4 embedded in a web application. An example of this is provided in the ServiceMix distribution.
JBI compatibility layer: The previous version of ServiceMix was based on JBI 1.0. For JBI a lot of components (from ServiceMix, but also from other parties), are available. This layer provides compatibility with the JBI specification, so that all the components from the previous version of ServiceMix can run on ServiceMix 4. Be sure though to use the 2009.01 version of these components.
Camel NMR: ServiceMix 4 provides a couple of different ways you can configure routing. You can use the endpoints provided by the ServiceMix NMR, but you can also use more advanced routing engines. One of those is the Camel NMR. This component allows you to run Camel based routes on ServiceMix.
CXF NMR: Besides an NMR based on Camel, ServiceMix also provides an NMR based on CXF. You can use this NMR to expose and route to Java POJOs annotated with JAX-WS annotations.
![Hot Tip](../../../../../../../../../../../Downloads/_refcardz_html/images/hot_tip.gif)
OSGi runtime
ServiceMix runs on an OSGi based kernel, but what is OSGi? In short an OSGi container provides a service based in-VM platform on which you can deploy services and components dynamically. OSGi provides strict classloasing seperation and forces you to think about the dependencies your components have. Besides that OSGi also defines a simple lifecycle model for your services and components. This results in an environment where you can easily add and remove components and services at runtime and allows the creation of modular applications. An added advantage of using an OSGi container is that you can use many components out of the box: remote administration, a web container, configuration and preferences services, etc.
Before we move on to the next part, let's have a quick look at how a message is processed by ServiceMix. The following figure shows how a message is routed by the NMR. In this case we're showing a reply / response (in-out) message pattern.
![Reply/Response Pattern](../../../../../../../../../../../Downloads/_refcardz_html/images/rc065-010d-servicemix/rc065-010d-servicemix-3.jpg)
In this figure you can see a number of steps being executed:
- The consumer creates a message exchange for a specific service and sends a request.
- The NMR determines the provider this exchange needs to be sent to and queus the message for delivery. The provider accepts this message and executes its business logic.
- After the provider has finished processing, the response message is returned to the NMR.
- The NMR once again queues the message for delivery. This time to the consumer. The consumer accepts the message.
- After the response is accepted, the consumer sends a confirmation to the NMR.
- The NMR routes this confirmation to the provider, who accepts it and ends this message exchange.
Now that we've seen the architecture and how a message is handled by the NMR, we'll have a look at how to configure ServiceMix 4.