简体   繁体   中英

How can I improve the performance of the JbossFuse (v6.3) DSL route code?

APPLICATION INFO:

Code below: reads from IBM MQ queue and then posts the message to a REST service

( note : reading from the MQ queue is fast and not an issue - rather, it is the post operation performance I am having trouble improving)...

PROBLEM:

Unable to output/post more than 44-47 messages per second...

QUESTION:

How can I improve the performance of the JbossFuse (v6.3) DSL route code below?... (What techniques are available that would make it faster?)

package aaa.bbb.ccc;

import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.cdi.ContextName;

@ContextName("rest-dsl")
public class Netty4HttpSlowRoutes extends RouteBuilder {

    public Netty4HttpSlowRoutes() {
    }

    private final org.apache.camel.Processor proc1 = new Processor1();    

    @Override
    public void configure() throws Exception {

    org.apache.log4j.MDC.put("app.name", "netty4HttpSlow");

    System.getProperties().list(System.out);
    errorHandler(defaultErrorHandler().maximumRedeliveries(3).log("***FAILED_MESSAGE***"));   

    from("wmq:queue:mylocalqueue")
        .log("inMessage=" + (null==body()?"":body().toString()))
        .to("seda:node1?concurrentConsumers=20");

    from("seda:node1")
        .streamCaching()
        .threads(20)
        .setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.POST))
        .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
        .toD("netty4-http:http://localhost:7001/MyService/myServiceThing?textline\\=true");      
    }           
}

Just a couple of thoughts. First things first: did you measure the slowness? How much time do you spend in Camel VS how much time you spend sending the HTTP request?
If the REST service is slow there's nothing you can do in Camel. Depending on what the service does, you could try reducing the number of threads.

Try to disable streamCaching since it looks like you're not using it.

Then use a to instead of toD to invoke the service, I see that the URL is always the same. In the docs of ToD I read

By default the Simple language is used to compute the endpoint.

There may be a little overhead while parsing the URI string each time you invoke the route.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM