NMR
Page edited by Piotr Klimczak
Changes (4)
...
{code}
h3. Installing in plain Apache Karaf
In plain Karaf the nmr component can also be installed using the servicemix artifacts:
...
{code}
Automatically exposes a new endpoint to the bus with endpoint name {{MyServiceEndpoint}} (see [URI-format|#URI-format]).
When an NMR endpoint appears at the end of a route, for example:
...
{div:class=confluenceTableSmall} || Option || Default Value || Description ||
| {{runAsSubject}} | {{false}} | *Apache ServiceMix 4.4:* When this is set to *{{true}}* {{{*}true{*}}} on a consumer endpoint, the endpoint will be invoked on behalf of the {{Subject}} that is set on the {{Exchange}} (i.e. the call to {{Subject.getSubject(AccessControlContext)}} will return the {{Subject}} instance) | | {{synchronous}} | {{false}} | When this is set to *{{true}}* {{{*}true{*}}} on a consumer endpoint, an incoming, synchronous NMR Exchange will be handled on the senders thread instead of being handled on a new thread of the NMR endpoints thread pool |
| {{timeout}} | {{0}} | *Apache ServiceMix 4.4:* When this is set to a value greater than 0, the producer endpoint will timeout if it doesnt receive a response from the NMR within the given timeout period (in milliseconds). Configuring a timeout value will switch to using synchronous interactions with the NMR instead of the usual asynchronous messaging. |
| {{throwExceptionOnFailure}} | true | *Apache ServiceMix 4.5.2:* When this is set to {{{*}false{*}}} then NMRs exceptions (like TimeoutException) will be consumed silently. |
{div}
...
Full Content
NMR Component
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.
Installing in Apache Servicemix
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:
features:install nmr camel-nmr
Installing in plain Apache Karaf
In plain Karaf the nmr component can also be installed using the servicemix artifacts:
features:chooseurl camel version
features:addurl mvn:org.apache.servicemix.nmr/apache-servicemix-nmr/1.5.0/xml/features
features:install camel-blueprint nmr camel-nmr
install -s mvn:org.apache.servicemix.camel/org.apache.servicemix.camel.component/4.4.2
Configuration
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:
beans xmlns:osgi="http://www.springframework.org/schema/osgi" ...
...
bean id="nmr" class="org.apache.servicemix.camel.nmr.ServiceMixComponent"
property name="nmr"
osgi:reference interface="org.apache.servicemix.nmr.api.NMR" /
/property
/bean
...
/beans
NMR consumer and producer endpoints
The following code:
from("nmr:MyServiceEndpoint")
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:
to("nmr:MyServiceEndpoint")
The messages sent by this producer endpoint are sent to the already deployed NMR endpoint.
URI format
nmr:endpointName
URI Options
Option
Default Value
Description
runAsSubject
false
Apache ServiceMix 4.4: When this is set to true on a consumer endpoint, the endpoint will be invoked on behalf of the Subject that is set on the Exchange (i.e. the call to Subject.getSubject(AccessControlContext) will return the Subject instance)
synchronous
false
When this is set to true on a consumer endpoint, an incoming, synchronous NMR Exchange will be handled on the sender's thread instead of being handled on a new thread of the NMR endpoint's thread pool
timeout
0
Apache ServiceMix 4.4: When this is set to a value greater than 0, the producer endpoint will timeout if it doesn't receive a response from the NMR within the given timeout period (in milliseconds). Configuring a timeout value will switch to using synchronous interactions with the NMR instead of the usual asynchronous messaging.