Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This means you can write JBI POJOs to be deployed by Spring without deriving from some helper base class like ServiceMix's ComponentSupport so that your POJO has no dependency other than on the JBI APIs and then let ServiceMix take care of more of the plumbing for you.To see this in use, take a look at this example. The Spring XML looks about the same as the regular JBI component examples, the difference is the implementation classes are simpler POJOs.

Example

First here's how we configure the two components in ServiceMix. Notice that ServiceMix is doing the routing here using destinationService.

Wiki Markup
{snippet:id=example|lang=xml|url=http://cvs.servicemix.codehaus.org/*checkout*/servicemix/base/src/test/resources/org/servicemix/components/pojo/example.xml?rev=HEAD}

Now lets look at the sender POJO. The sendMessages() method will send messages onto the JBI bus to the destination service specified in the above XML.

Wiki Markup
{snippet:id=send|lang=java|url=http://cvs.servicemix.codehaus.org/*checkout*/servicemix/base/src/test/java/org/servicemix/components/cache/MySender.java?rev=HEAD}

Then the receiver processes inbound messages as follows.

Wiki Markup
{snippet:id=receive|lang=java|url=http://cvs.servicemix.codehaus.org/*checkout*/servicemix/base/src/test/java/org/servicemix/components/cache/MyReceiver.java?rev=HEAD}