camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller <christian.muel...@gmail.com>
Subject Camel Exchange Patters
Date Sat, 11 Sep 2010 14:03:37 GMT
Hello list!

I read Claus, Jonathan and Hadrians book Camel in Action and I studied the
Camel site [1]. I also hat a short conversation with Ade from Progress about
the exchange pattern, but still I have the feeling I doesn't understand all
aspects. May be you can help me to understand it correct. Here are my
questions:
- In the book and the Camel site only the exchange patterns InOut and InOnly
are mentioned but org.apache.camel.ExchangePattern defines the following
exchange patterns: InOnly, RobustInOnly, InOut, InOptionalOut, OutOnly,
RobustOutOnly, OutIn, OutOptionalIn. Should we only use InOut and InOnly?
- If I understood Ade correct, after each processing on a
component/processor the message goes throught the pipieline before it
receives the next component/processor. In the case of an InOut exchange, the
pipeline will copy the out message body, headers and attachments into the in
message. So that in the next component/processor can access these data from
the in message again. If I use the InOnly exchange pattern, the
component/processor will write the response into the in message and the
pipeline has nothing to copy. From the end user perspective it looks like it
doesn't matter, whether to use the InOnly or InOut exchange pattern.
- The only one component I know which handle InOnly and InOut "really"
defferently is the jms-component. It will only send a reply message if the
exchange pattern InOut is used.
- If I use a InOnly exchange for the following routes, I takes also more
than 5 seconds until my templeate.send() method returns. I would expect that
the call returns after the exchange was placed into the next sub route
(after a few milliseconds). My key point here is not to improve the
performance. Only to understand the exchange pattern correct, how the work
and how they are used in the right way...

                from("direct:start")

                .to("direct:sub");



                from("direct:sub")

                .process(*new* Processor() {

                             @Override

                             *public* *void* process(Exchange exchange) *
throws* Exception {

                                   Thread.*sleep*(5000);

                             }

                        })
                .to("mock:result");


- Do you have recommendations when to use InOnly and InOut?
- If we write our own processor which modifies the in message, should they
write the modified body into the out message, if the exchnage is out capable
(and also copy all header and attachments we need for further processing)?
Or should we always modify the in message because it requires less action?
- The same question for our own type converters. I know the type converter
is implemented in this way, that it will return the new (converted) object.
But our type converters also have to modify the message header. Should they
also check whether the exchange is out capable and than modify the out (if
out capable) or in (if not out capable) message? Is this the way camel
handels the converted object from the type converter?

[1] http://camel.apache.org/exchange-pattern.html

Thanks in advance for your help and taking time for my questions,
Christian

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