title: How to use choice in try catch block using apache Camel in a Route with Java DSL
body: <p>How to use choice in try catch block using Apache Camel in a Route with Java DSL?</p>
  
  <p>I have a situation in which, I need the following structure:</p>
  
  <blockquote>
    <p>route-->from--> doTry-->choice-->when-->simple-->to-->otherwise-->to-->enddoTry-->docatch-->to-->enddocatch-->endroute</p>
  </blockquote>
  
  <p>As of now I tried below lines:</p>
  
  <pre><code>    .doTry()
      .choice()
      .when(header("CamelFileName").contains("xxxxx"))
      .to()
      .otherwise().to("controlbus:route?routeId=XXXX&amp;action=stop")
      .doCatch(java.lang.Exception.class)
      .log("STOPPING ROUTE")
      .to("controlbus:route?routeId=XXXX&amp;action=stop&amp;async=true")
  </code></pre>
  
  <p>But I am getting "<strong>cannot find symbol</strong>" error at <code>docatch()</code></p>
  
  <p>Could you please suggest way to use "choice" in try catch block with Java DSL?</p>