Ammamon
Ammamon

Reputation: 497

Can I pipeline within content based router?

Can I pipeline within a content based router? I have to pipeline beans within a content-based router. For that, I adopted the following configuration. I hope the configuration itself explains my requirements. Is it correct? Do I have to add the end() tag also?

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

Upvotes: 1

Views: 1335

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55545

Yes this is correct what you do.

Camel runs in pipeline mode by default (eg the pipes and filters EIP - http://camel.apache.org/pipes-and-filters.html), but if you want you can make that explicit using < pipeline >. eg

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

But very often you would omit the < pipeline > and do as your example.

Opposed to pipeline there is multicast (http://camel.apache.org/multicast.html), and when you combine these two, then you may need to use pipeline eg

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

Upvotes: 3

Related Questions