Hi
Med venlig hilsen Claus Ibsen ...................................... Silverbullet Skovsgårdsvænget 21 8362 Hørning Tlf. +45 2962 7576 Web: www.silverbullet.dk -----Original Message----- From: Vlad Olenin [mailto:[EMAIL PROTECTED] Sent: 16. juli 2008 22:23 To: [email protected] Subject: Re: route definition: component response routing Thanks for the detailed explanation, Claus. Can you clarify couple of points: -- As a rule of thumb if you use the ProducerTemplate to send exchanges to Camel then you can use the requestXXX to force the InOut pattern and thus you get the response from the OUT message. The others methods uses the default exchange pattern that usually is InOnly. -- What are the other methods? I though the ProducerTemplate is the only one, except for probably 'Endpoint' annotation injection. How one can initiate async request? Is it possible to do through the ProducerTemplate? If 'seda' is the first component in the chain, would the ProducerTemplate.requestXXX call block or just return null? [CI] sendBodyXXX methods doens't considers the exchange pattern so the body that is returned could be the IN body instead of the OUT body. [CI] Yes the ProducerTemplate is great for sending exchanges. But you can also do it manually without the template: Beware mail code: Endpoint endpoint = context.getEndpoint Exchange exchange = endpoint.createExchange Producer exchange.createProducer Exchange.getin.setbody("blab bla") Producer.start Producer.process(exchange) Producer.stop -- To do this you should put another route type as the from to invoke the chain such as direct:start. -- I didn't realize there is some restriction on the first component in the chain within the Camel. What are the other options, beyond 'direct' component? Can 'seda' be the first in the chain? [CI] No I do think Bean is the special case in your route. Check this unit test http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/SendBodyToBeanDirectlyTest.java?view=markup Yes you can use anyone in front such as seda as well. Just make sure to use pipeline if you need bean to bean routing. Maybe James can enlighten why, but I guess its because bean can lookup any bean in the registry also spring beans and invoke whatever method on them, so the bean its not a "Camel route component" = the bean is not a producer or consumer etc. so Camel will not route it by default, you have to instruct it using the pipeline etc. So in your case you are just invoking a method on a bean. To route it you need to use a real Camel producer such as direct, and then wrap beans in the pipeline if you need beans to call beans. Thanks, Vlad On Fri, Jul 11, 2008 at 1:26 AM, Claus Ibsen <[EMAIL PROTECTED]> wrote: > Hi Vlad > > We have a discussion on the dev forum about the exchange patterns in Camel > and what we should do about it for e.g. Camel 2.0. > > I agree they are confusing and as I understand it they were introduced > because of JBI and CXF containers needed this meta information. > > The exchange patterns isn't strictly checked/forced in Camel in its > components and other parts of the framework. So basically you can send an > exchange with the pattern InOut to a component that's InOnly (such as the > SEDA). > > As a rule of thumb if you use the ProducerTemplate to send exchanges to > Camel then you can use the requestXXX to force the InOut pattern and thus > you get the response from the OUT message. The others methods uses the > default exchange pattern that usually is InOnly. > > However all this is hopefully changing for the better in Camel 2.0. I > personally would love to simply this much more and only have two patterns: > - sync (InOut) > - async (InOnly) > And then a more strickt ruling in Camel to force this behavior. > > Well we should discuss this on the dev forum. You are welcome to join. > > > In your example the Object response is the response from "bean:xxx", > because Camel will just invoke your bean and not the full route path. > > To do this you should put another route type as the from to invoke the > chain such as direct:start. > > from("direct:start") > .pipeline("bean:xxx", "bean:yyy", "direct:z", "direct:x", "bean:result") > > > > Med venlig hilsen > > Claus Ibsen > ...................................... > Silverbullet > Skovsgårdsvænget 21 > 8362 Hørning > Tlf. +45 2962 7576 > Web: www.silverbullet.dk > -----Original Message----- > From: Vlad Olenin [mailto:[EMAIL PROTECTED] > Sent: 10. juli 2008 21:29 > To: [email protected] > Subject: Re: route definition: component response routing > > Yes, I actually meant smth like this. For example, for a more complex > route: > > from("bean:xxx") > .pipeline("bean:yyy", "direct:z", "direct:x", "bean:result") > > when I call it with > > Object response = template.requestBody("bean:xxx", "Hello"); > assertEquals("Hello World", response); > > what is the preferred way to retrieve a response: from the "bean:result" > request object, or from the result of evaluation of the initial call? In > case of the various pipelines and routers chained together, would the > response be propogated back? In which cases it woudn't? I'm assuming if > there is a 'seda' component in the chain, the only option to get the result > would be from the 'bean:result' (the last component in the chain), correct? > > In other words, how to define / know the channel type: 'in-only', 'in-out', > 'in-optional out', etc... > > Thanks, > > Vlad > > > On Tue, Jul 8, 2008 at 6:57 AM, Claus Ibsen <[EMAIL PROTECTED]> wrote: > > > Hi > > > > Vladim could you give an example? I read your question a bit differently > > than Charles. > > > > If you mean what Camel does if you have a route like this? > > > > from("xxx") > > > > And you send an exchange to "xxx". Then Camel will process the exchange > and > > return a response to the client. > > > > Eg: as this unit test demonstrates: > > > > public void testNoToType() throws Exception { > > Object response = template.requestBody("direct:in", "Hello"); > > assertEquals("Hello World", response); > > } > > > > protected RouteBuilder createRouteBuilder() throws Exception { > > return new RouteBuilder() { > > public void configure() throws Exception { > > from("direct:in").process(new Processor() { > > public void process(Exchange exchange) throws > Exception > > { > > String body = > > exchange.getIn().getBody(String.class); > > exchange.getOut(true).setBody(body + " World"); > > } > > }); > > } > > }; > > } > > > > > > Med venlig hilsen > > > > Claus Ibsen > > ...................................... > > Silverbullet > > Skovsgårdsvænget 21 > > 8362 Hørning > > Tlf. +45 2962 7576 > > Web: www.silverbullet.dk > > > > -----Original Message----- > > From: cmoulliard [mailto:[EMAIL PROTECTED] > > Sent: 8. juli 2008 09:05 > > To: [email protected] > > Subject: Re: route definition: component response routing > > > > > > Hi Vlad, > > > > If the destination endpoint is not defined, an error will be generated > when > > your message will be send. Different strategies exist to avoid to lost > your > > message in this situation : > > > > - Implement a DeadLetterchannel, > > - Define your "from" endpoint as a transactional endpoint to provide a > > rollback > > > > Regards, > > > > Charles > > > > > > volenin wrote: > > > > > > Does anyone have any suggestion re: this question?... > > > > > > > > > On Sun, Jun 29, 2008 at 5:47 PM, Vlad Olenin <[EMAIL PROTECTED]> > wrote: > > > > > >> Hi, > > >> > > >> I was browsing through the documentation recently trying to find the > > >> answer > > >> for the following question. If the outbound route from one of the > > >> endpoints > > >> is not defined, does it mean that the response that component is > > creating > > >> would be propagated back through the request chain? Or it would just > > >> terminate on that endpoint? In other words, does Camel behavior in > this > > >> case > > >> resembles that of Mule or not? (From what I read, in Mule if the > > outbound > > >> route is not defined, the message would 'bounce back' along the > > >> invocation > > >> chain towards the original caller). > > >> > > >> Thanks, > > >> > > >> Vlad > > >> > > > > > > > > > > -- > > View this message in context: > > > http://www.nabble.com/route-definition%3A-component-response-routing-tp18185736s22882p18333101.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > > > >
