Apache camel 如何扩展Apache Camel路线?
我有以下路线:Apache camel 如何扩展Apache Camel路线?,apache-camel,Apache Camel,我有以下路线: <camelContext xmlns="http://camel.apache.org/schema/spring"> <threadPoolProfile id="defaultProfile" defaultProfile="true" poolSize="100" maxPoolSize="200" /> <route> <from uri="amq:example.MyQueue
<camelContext xmlns="http://camel.apache.org/schema/spring">
<threadPoolProfile id="defaultProfile"
defaultProfile="true" poolSize="100" maxPoolSize="200" />
<route>
<from uri="amq:example.MyQueue" />
<setHeader headerName="myRoutingSlipHeader">
<constant>amq:one#amq:two#amq:three#amq:four</constant>
</setHeader>
<log message="Makan" />
<setExchangePattern pattern="InOut" />
<routingSlip uriDelimiter="#">
<header>myRoutingSlipHeader</header>
</routingSlip>
<setExchangePattern pattern="InOnly" />
<log message="End: ${body}" />
</route>
<route>
<from uri="amq:one" />
<to uri="bean:helloBean?method=stepOne" />
</route>
<route>
<from uri="amq:two" />
<to uri="bean:helloBean?method=stepTwo" />
</route>
<route>
<from uri="amq:three" />
<to uri="bean:helloBean?method=stepThree" />
</route>
<route>
<from uri="amq:four" />
<to uri="bean:helloBean?method=stepFour" />
</route>
</camelContext>
<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent"
p:brokerURL="tcp://localhost:61616" p:transacted="true"
p:cacheLevelName="CACHE_CONSUMER" p:concurrentConsumers="20"
p:maxConcurrentConsumers="500" p:idleConsumerLimit="10"
/>
amq:1#amq:2#amq:3#amq:4
myRoutingSlipHeader
考虑到example.MyQueue预加载了1000条消息,每个HelloBean的step*方法需要250毫秒,当我执行camel:run时,性能仍然很差。它以不平行的顺序每1秒打印一次“结束:…”。这里有什么问题
在下面这个非常简单的例子中,我看到了一个奇怪的行为。当没有JMS生产者将消息放入队列时,打印将按顺序进行。但如果有,打印将并行进行。怎么解释
<threadPoolProfile id="defaultProfile"
defaultProfile="true" poolSize="100" maxPoolSize="200" />
<route>
<from uri="amq:example.MyQueue" />
<delay>
<constant>1000</constant>
</delay>
<log message="End: ${body}" />
</route>
<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent"
p:brokerURL="tcp://localhost:61616" p:transacted="true"
p:cacheLevelName="CACHE_CONSUMER" p:concurrentConsumers="20"
p:maxConcurrentConsumers="500" p:idleConsumerLimit="10"
/>
1000
路由滑条按顺序运行,并且通过JMS进行请求/回复(例如MEP是InOut),因此处理一条消息需要花费大量时间
- 呼叫amq:one=250毫秒(请求/回复)
- 呼叫amq:two=250毫秒(请求/回复)
- 呼叫amq:three=250毫秒(请求/回复)
- 呼叫amq:four=250毫秒(请求/回复)
- 呼叫amq:one=250毫秒(请求/回复)
- 呼叫amq:two=250毫秒(请求/回复)
- 呼叫amq:three=250毫秒(请求/回复)
- 呼叫amq:four=250毫秒(请求/回复)
只有一个问题,为什么需要设置ExchangePattern?我想routingSlip模式是同步的。您需要一些异步化组件来处理这个问题。请检查以下内容: 只有一个问题,为什么需要设置ExchangePattern?尝试替换
<from uri="amq:example.MyQueue" />
与
尝试更换
<from uri="amq:example.MyQueue" />
与
我知道。问题是如何使它平行?我知道。问题是如何使其并行?没有ExchangePattern,bean调用的结果不会反映在最后一个日志中。没有ExchangePattern,bean调用的结果不会反映在最后一个日志中。