Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Spring Remoting

We support Spring Remoting in Camel. The implementing of Spring Remoting uses Camel as the underlying transport mechanism. The nice thing about this approach is we can use any of the Camel transport Components to communicate between beans.

It also means we can use Content Based Router and the other Enterprise Integration Patterns in between the beans; in particular we can use Message Translator to be able to convert what the on-the-wire messages look like in addition to adding various headers and so forth.

Using Camel Spring Remoting

In your Spring XML just use the CamelProxyFactoryBean to create a client side proxy implementing some interface which then sends messages to some remote Camel Endpoint such as ActiveMQ, JMS, File, HTTP, XMPP etc.

Then to implement the service you use CamelServiceExporter

The following example shows how to create a proxy which when invoked with fire a message to the direct:say endpoint

Wiki Markup
{snippet:id=proxy|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter.xml}

Then we expose the service on an endpoint so that messages from direct:sayImpl will be dispatched to the service (note that we have a route in between these two endpoints).

Wiki Markup
{snippet:id=export|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter.xml}

Using Custom Namespaces

In this example we use the Camel custom namespaces to make the XML much more concise. First, create a proxy via the proxy element

Wiki Markup
{snippet:id=proxy|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-namespace.xml}

Then we expose the service via the export element

Wiki Markup
{snippet:id=export|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-namespace.xml}

Its much cleaner - use whichever approach you prefer as they are both equivalent.

ServiceExporter is Optional

Note that the service is not mandatory; since the Bean component and the various other forms of Bean Integration can be used to route any message exchange to a bean, so you can miss out the serviceExporter if you prefer. The main value of the service exporter is its a single XML element to bind a URI to a bean and it allows the full API of the bean to be restricted by a serviceInterface.

Working with InOnly method calls

As of 1.5 Camel supports the @InOnly and @Pattern annotations to let you specify which methods are not InOut (Request Reply) but are InOnly (oneway or fire and forget Event Message).

For more details see Using Exchange Pattern Annotations

Include Page
Bean Binding
Bean Binding