camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Siefert" <>
Subject Explanation of MEPs within Camel
Date Thu, 17 Apr 2008 16:12:39 GMT

I could use some explanation of how MEPs are used within Camel.  I
understand the various Message Exchange Patterns (in, out, inout), but I am
having some trouble with how I design my processor.  I need to take an XML
document and move some of the information from the body to header
properties.  To do this I took the input message, parsed the body to get the
information I needed.  Then I set that data on the output message, and set a
body for the output message.  I created a test to verify the work was done,
but it fails.  I end up getting what looks like the input message.

Here is the test code snippet:
  MockEndpoint result = // get mock...
  template.sendBody("direct:start", "<sample><name>value</name></sample>");
My route is configured as follows:
  from("direct:start").process(new MyProcessor()).to("mock:result");

MyProcessor works like so:
  public void process(Exchange exchange) throws Exception {
   Document document = // read exchange.getIn().getBody(String.class)

   String value = // parse for the text of <name> element.

   Message output = exchange.getOut();
   output.setHeader("", value);
   output.setBody(/* XML of new body */);
When I run the test, it will say:
  INFO: Asserting: Endpoint[mock:result] is satisfied

But the test fails:
  java.lang.AssertionError: mock:result Body of message: 0. Expected: <> but
was: <...(body of input message here)...>

It doesn't really appear that it is even making assertions about the header
properties either.  What I am trying to understand is why the input message
gets sent to mock:result and not the output message.  Should I modify the
input message only and forget about the output message?  Please help.

I looked at some of the test code for various processors, and it looks like
you have to specify a Processor parameter that will receive an endpoint
specification from to().  Then it calls that processor's process() method
with the output message.  I don't really understand the point of this if you
have an output message in the Exchange.  Wouldn't Camel automagically take
the output of the exchange and send it to its next destination?



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message