【发布时间】:2017-11-17 18:25:18
【问题描述】:
申请信息:
以下代码:从 IBM MQ 队列中读取,然后将消息发布到 REST 服务
(注意:从 MQ 队列读取速度很快,不是问题 - 而是 post 操作性能我无法改进)...
问题:
每秒无法输出/发布超过 44-47 条消息...
问题:
如何提高下面的 JbossFuse (v6.3) DSL 路由代码的性能?... (有哪些技术可以使其更快?)
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");
}
}
【问题讨论】:
-
您的争论是从 MQ 读取消息还是将它们发布到 REST 服务?
-
发布到其余服务。 mq 读取速度很快。
-
我是 MQ 管理员,所以对于 REST 服务端没有任何建议。
-
我明白了!谢谢,乔什麦克! :-)