camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andres Olarte <olarte.and...@gmail.com>
Subject Multithreaded REST services with Camel and Restlet
Date Mon, 02 Feb 2015 13:57:25 GMT
Hello,


I have a very simple REST endpoint in Camel, which takes some text and
returns the text in upper case. My routes work fine, but it can only
service one client at a time. If I connect with a second client, it
will wait until the first one finishes. How can I configure camel to
serve several clients at once?

According to the documentation here (
http://camel.apache.org/restlet.html ), it should have a maximum of 10
threads, but only one is created.

This is my code:

public class MyRouteBuilder extends RouteBuilder{
    @Override
    public void configure() throws Exception {
rest("/").post("/UP").route().setExchangePattern(ExchangePattern.InOut).convertBodyTo(String.class).to("direct:up");

        from("direct:up").process(new Processor() {
               public void process(Exchange msg) {
                    System.err.println("Processing ******************** ");
                    try {
                        Thread.sleep(10000);
                    } catch (InterruptedException e) {
                    }
                    String body= msg.getIn().getBody().toString();
                    msg.getOut().setBody(body.toUpperCase());;

                }
            });

        restConfiguration().bindingMode(RestBindingMode.auto).component("restlet").port(9999).setBindingMode(RestBindingMode.auto);
        }

}

This is how I'm starting Camel:

public class JavaMain extends Main{

    static Logger LOG = LoggerFactory.getLogger(JavaMain.class);

    public static void main(String... args) throws Exception {
        BasicConfigurator.configure();
        JavaMain main = new JavaMain();
        main.enableHangupSupport();
        main.addRouteBuilder(createRouteBuilder());
        main.run(args);
    }
    static RouteBuilder createRouteBuilder() {
        //return new TestRouteBuilder();
        return new MyRouteBuilder();
    }

}

I'm using Camel version 2.14.1.


Thanks,

Andres

Mime
View raw message