Apache camel 我可以在基于内容的路由器中使用管道吗?

Apache camel 我可以在基于内容的路由器中使用管道吗?,apache-camel,Apache Camel,我可以在基于内容的路由器中使用管道吗? 我必须在基于内容的路由器中使用管道bean。为此,我采用了以下配置。我希望配置本身能够解释我的需求。对吗? 是否还必须添加end()标记 <route> <from uri="activemq:queue:injob"/> <choice> <when> <simple>${header.type} == 'heartbeat'</simple>

我可以在基于内容的路由器中使用管道吗? 我必须在基于内容的路由器中使用管道bean。为此,我采用了以下配置。我希望配置本身能够解释我的需求。对吗? 是否还必须添加end()标记

<route>
  <from uri="activemq:queue:injob"/>
  <choice>
    <when>
       <simple>${header.type} == 'heartbeat'</simple>
       <to uri="bean:heartBeatHandler"/>
       <to uri="activemq:queue:outjob"/>
    </when>
    <when>
      <simple>${header.type} == 'dnsrequest'</simple>
      <to uri="bean:dnsRequestHandler"/>
      <to uri="bean:parser"/>
      <to uri="activemq:queue:outjob"/>
    </when>
    <when>
      <simple>${header.type} == 'whoisrequest'</simple>
      <to uri="bean:whoisRequestHandler"/>
      <to uri="bean:parser"/>
      <to uri="activemq:queue:outjob"/>
    </when>
    <otherwise>
      <to uri="bean:errorHandler"/>
    </otherwise>
  </choice>
</route>

${header.type}=='heartbeat'
${header.type}=='dnsrequest'
${header.type}=='whoisrequest'

是的,这是正确的做法

默认情况下,Camel以管道模式运行(例如管道和过滤器EIP-),但如果需要,可以使用使其显式运行。乙二醇

<when>
   <simple>${header.type == 'heartbeat'}</simple>
   <pipeline>
     <to uri="bean:heartBeatHandler"/>
     <to uri="activemq:queue:outjob"/>
   </pipeline>
</when>

${header.type=='heartbeat'}
但通常情况下,您会忽略,并按照您的示例进行操作

与管道相反的是多播(),当您将这两者结合起来时,您可能需要使用管道

<multicast>
  <pipeline>
     <to uri="bean:heartBeatHandler"/>
     <to uri="activemq:queue:outjob"/>
   </pipeline>
  <pipeline>
     <to uri="bean:somethingElse"/>
     <to uri="activemq:queue:somethingElse"/>
   </pipeline>
</multicast>


Btw您的简单表达式有点错误,应该是${header.type}=='whoisrequest'非常感谢克劳斯的回答。注意到您在简单表达式中提到的更正。