2

次のルートがあります。

<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"
     />

example.MyQueue に 1000 個のメッセージがプリロードされており、各 hello Bean の step* メソッドが 250 ミリ秒かかることを考えると、camel:run を実行すると、パフォーマンスは依然として悪いです。"End: ..." を 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"
     />
4

3 に答える 3

1

交換してみる

   <from uri="amq:example.MyQueue" />

   <from uri="amq:example.MyQueue?concurrentConsumers=200&amp;maxConcurrentConsumers=500" />
于 2015-05-13T13:03:09.577 に答える
0

routingSlip パターンが同期されていると思います。これを処理するには、非同期コンポーネントが必要です。これを確認してください: http://camel.apache.org/async.html

1 つだけ質問があります。なぜ ExchangePattern を設定する必要があるのですか?

于 2013-10-06T02:31:02.987 に答える
0

ルーティング スリップは順番に実行され、JMS を介して要求/応答を行う (たとえば、MEP は InOut である) ため、1 つのメッセージを処理するのに時間がかかります。

  • call amq:one = 250 ミリ秒 (要求/応答)
  • call amq:two = 250 ミリ秒 (要求/応答)
  • call amq:three = 250 ミリ秒 (要求/応答)
  • call amq:four = 250 ミリ秒 (要求/応答)

メッセージごとに合計 1 秒。

ただし、 < from > の AMQ ルートは、メッセージを並行して処理できます。ただし、各メッセージの処理にはまだ 1 秒かかります。

于 2013-10-04T07:08:41.257 に答える