The nmr component is an adapter to the Normalized Message Router (NMR) in ServiceMix, which is intended for use by Camel applications deployed directly into the OSGi container. You can exchange objects with NMR and not only XML like this is the case with the JBI specification. The interest of this component is that you can interconnect camel routes deployed in different OSGI bundles.
By contrast, the JBI component is intended for use by Camel applications deployed into the ServiceMix JBI container.
The NMR component is provided with Apache ServiceMix. It is not distributed with Camel. To install the NMR component in ServiceMix, enter the following command in the ServiceMix console window:
In plain Karaf the nmr component can also be installed using the servicemix artifacts:
You also need to instantiate the NMR component. You can do this by editing your Spring configuration file, META-INF/spring/*.xml, and adding the following bean instance:
The following code:
Automatically exposes a new endpoint to the bus with endpoint name MyServiceEndpoint (see URI-format).
When an NMR endpoint appears at the end of a route, for example:
The messages sent by this producer endpoint are sent to the already deployed NMR endpoint.
If you are using a stream type as the message body, you should be aware that a stream is only capable of being read once. So if you enable DEBUG logging, the body is usually logged and thus read. To deal with this, Camel has a streamCaching option that can cache the stream, enabling you to read it multiple times.
The stream caching is default enabled, so it is not necessary to set the streamCaching() option.
NMR camel routes can be tested using the camel unit test approach even if they will be deployed next in different bundles on an OSGI runtime. With this aim in view, you will extend the ServiceMixNMR Mock class org.apache.servicemix.camel.nmr.AbstractComponentTest which will create a NMR bus, register the Camel NMR Component and the endpoints defined into the Camel routes.