Red Hat DocumentationRed Hat JBoss FuseToggle FramesPrintFeedback

Migrating Endpoints

Overview

A typical ServiceMix EIP route exposes a service that consumes exchanges from the NMR. The route also defines one or more target destinations, to which exchanges are sent. In the Apache Camel environment, the exposed ServiceMix service maps to a consumer endpoint and the ServiceMix target destinations map to producer endpoints. The Apache Camel consumer endpoints and producer endpoints are both defined using endpoint URIs.

When migrating endpoints from ServiceMix EIP to Apache Camel, you must express the ServiceMix services/endpoints as Apache Camel endpoint URIs. You can adopt one of the following approaches:

  • Connect to an existing ServiceMix service/endpoint through the ServiceMix Camel module (which integrates Apache Camel with the NMR).

  • If the existing ServiceMix service/endpoint represents a ServiceMix binding component, you can replace the ServiceMix binding component with an equivalent Apache Camel component (thus bypassing the NMR).

The ServiceMix Camel module

The integration between Apache Camel and ServiceMix is provided by the servicemix-camel module. This module is provided with ServiceMix, but actually implements a plug-in for the Apache Camel product: the JBI component (see JBI in EIP Component Reference and JBI Component).

To access the JBI component from Apache Camel, make sure that the servicemix-camel JAR file is included on your Classpath or, if you are using Maven, include a dependency on the servicemix-camel artifact in your project POM. You can then access the JBI component by defining Apache Camel endpoint URIs with the jbi: component prefix.

Translating ServiceMix URIs into Apache Camel endpoint URIs

ServiceMix defines a flexible format for defining URIs, which is described in detail in ServiceMix URIs. To translate a ServiceMix URI into a Apache Camel endpoint URI, perform the following steps:

  1. If the ServiceMix URI contains a namespace prefix, replace the prefix by its corresponding namespace.

    For example, after modifying the ServiceMix URI, service:test:messageFilter, where test corresponds to the namespace, http://progress.com/demos/test, you get service:http://progress.com/demos/test:messageFilter.

  2. Modify the separator character, depending on what kind of namespace appears in the URI:

    • If the namespace starts with http://, use the / character as the separator between namespace, service name, and endpoint name (if present).

      For example, the URI, service:http://progress.com/demos/test:messageFilter, would be modified to service:http://progress.com/demos/test/messageFilter.

    • If the namespace starts with urn:, use the : character as the separator between namespace, service name, and endpoint name (if present).

      For example, service:urn:progress:com:demos:test:messageFilter.

  3. Create a JBI endpoint URI by adding the jbi: prefix.

    For example, jbi:service:http://progress.com/demos/test/messageFilter.

Example of mapping ServiceMix URIs

For example, consider the following configuration of the static recipient list pattern in ServiceMix EIP. The eip:exchange-target elements define some targets using the ServiceMix URI format.

<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
       xmlns:eip="http://servicemix.apache.org/eip/1.0"
       xmlns:test="http://progress.com/demos/test" >
    ...
    <eip:static-recipient-list service="test:recipients" endpoint="endpoint">
      <eip:recipients>
        <eip:exchange-target uri="service:test:messageFilter" />
        <eip:exchange-target uri="service:test:trace4" />
      </eip:recipients>
    </eip:static-recipient-list>
    ...
</beans>

When the preceding ServiceMix configuration is mapped to an equivalent Apache Camel configuration, you get the following route:

<route>
  <from uri="jbi:endpoint:http://progress.com/demos/test/recipients/endpoint"/>
  <to uri="jbi:service:http://progress.com/demos/test/messageFilter"/>
  <to uri="jbi:service:http://progress.com/demos/test/trace4"/>
</route>

Replacing ServiceMix bindings with Apache Camel components

Instead of using the Apache Camel JBI component to route all your messages through the ServiceMix NMR, you can use one of the many supported Apache Camel components to connect directly to a consumer or a producer endpoint. In particular, when sending messages to an external endpoint, it is more efficient to send the messages directly through a Apache Camel component than sending them through the NMR and a ServiceMix binding.

For details of all the Apache Camel components that are available, see EIP Component Reference and Apache Camel Components.

Comments powered by Disqus