camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Stiborský <martin.stibor...@gmail.com>
Subject Simple route with restlet and text stream as the output
Date Thu, 18 Oct 2012 12:02:31 GMT
Hello guys,
I'm here again with probably quite obvious things that I haven't
understood or missed.
Let's describe my scenario. I want to provide REST interface on the
"from()" side of the Camel route, and HTML/JSON/XML/etc stream on the
other side, that is the "to()" side in Camel routes terms.

Right now, I don't have any "to()", because I don't know which
component I should use there for my purpose.
I just create the REST interface, then I do something in the route
with help of Processor and then send the result back with in
exchange.getOut().setBody().

I don't like that, I want to get rid of Processor and replace it with
bean(s), I'm working on that.
But what I should use as the "to()" side? Maybe my custom Component?
It's producer, right? It will be producing data (XML or JSON, or
whatever is the required format of data) computed by the inputs given
via REST interface.

Does Camel offers something what exactly match my situation?

Btw, here is a simple snippet, how it works for me right now:

from("restlet:{{rest.base}}/test")
            .process(new Processor() {
              @Override
              public void process(Exchange exchange) throws Exception {
                Response response =
exchange.getIn().getHeader(RestletConstants.RESTLET_RESPONSE,
Response.class);

                response.setEntity("test", MediaType.TEXT_PLAIN);
                exchange.getOut().setBody(response);
              }
            });


Thanks guys!

-- 
S pozdravem
Martin Stiborský

Jabber: stibi@njs.netlab.cz

Mime
View raw message