Using the @RecipientList annotation worked. The new component receives the
exchange that was modified by the bean method. Thanks Claus.


On Tue, Jul 10, 2012 at 12:33 AM, Claus Ibsen-2 [via Camel] <
ml-node+s465427n5715793...@n5.nabble.com> wrote:

> Hi
>
> There is a @RecipientList annotation you can use in a method in a bean.
> And then use a bean in the DSL, eg either .bean / .beanRef / or
> .to("bean:xxx") etc.
>
> Your use-case is a bit unusual as you set the body to null, and
> therefore accesses the Exchange directly.
>
> And accordingly to the EIPs you would need 2 eips for that
> - message translator
> - recipient list
>
> So in the end you may need to use 2 eips. But you can give the
> @RecipientList a try.
>
>
> On Mon, Jul 9, 2012 at 9:46 PM, rhowlett <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=5715793&i=0>>
> wrote:
>
> > I'm using the Java DSL to do something akin to the following:
> >
> > from("xxx")
> >         .setBody("<root><p>Hi</p></root>")
> >         .recipientList(method(MyBean.class, "myMethod"))
> > .end()
> >
> > MyBean's myMethod() method is intended to calculate the HTTP endpoint to
> > call:
> >
> > public String myMethod(
> >         @Body String body,
> >         @Headers Map<String, Object> inHeaders,
> >         @OutHeaders Map<String, Object> outHeaders,
> >         Exchange exchange
> > ) {
> >         outHeaders = inHeaders;
> >
> >         outHeaders.put(Exchange.HTTP_METHOD, "GET");
> >         exchange.getIn().setBody(null);
> >
> >         return "http://somewebservice.com";;
> > }
> >
> > The problem is because the body of the Exchange's In Message going into
> the
> > recipient list method is not null, an InvalidPayloadException is
> therefore
> > thrown.
> >
> > Setting the body within the method has no effect because it seems the
> > component used by the method's return value is passed the pre-recipient
> list
> > method's body.
> >
> > What I'm doing now is using two methods, one pre-recipientList method to
> > calculate/set the headers etc., and the recipientList's method itself
> just
> > returns the HTTP string now.
> >
> > What better ways are there of doing this? It would be nice to solve it
> with
> > one method. Use the HTTP component class directly?
> >
> > Thanks, R
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/RecipientList-with-bean-method-to-set-HTTP-endpoint-string-tp5715771.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: [hidden email]<http://user/SendEmail.jtp?type=node&node=5715793&i=1>
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/RecipientList-with-bean-method-to-set-HTTP-endpoint-string-tp5715771p5715793.html
>  To unsubscribe from RecipientList with bean method to set HTTP endpoint
> string, click 
> here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5715771&code=cmhvd2xldHRAc2lsdmVyY2hhbGljZS5jb218NTcxNTc3MXw1Nzk3MjE5MjQ=>
> .
> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: 
http://camel.465427.n5.nabble.com/RecipientList-with-bean-method-to-set-HTTP-endpoint-string-tp5715771p5715817.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to