title: Spring integration router with condition
body: <p>I have a header witch is incremented during flow, than message goes to a loop, where I route it based on this header value. I cant find a way to config this router.</p>
  <p>I found this question
  <a href="https://stackoverflow.com/questions/25393767/routing-to-a-different-channels-based-on-condition">Routing to a different channels based on condition</a></p>
  <p>but it uses payload instead of headers: &lt;expression=&quot;payload.score == 100&quot;&gt;</p>
  <p>I tried using Java config like this:</p>
  <pre><code>public ExpressionEvaluatingRouter router() {
          var router = new ExpressionEvaluatingRouter(&quot;payload.getHeaders().get(failCount) =&gt; 2&quot;);
          router.setChannelMapping(&quot;true&quot;, &quot;logFailedChannel&quot;);
          router.setChannelMapping(&quot;false&quot;, &quot;retryChannel&quot;);
          return router;
      }
  </code></pre>
  <p>But it fails as it can not parse this &quot;payload.getHeaders().get(failCount) =&gt; 5&quot;</p>
  <p>I also tried using HeaderRouner, but it wasn't good for me, because I had to hardcode every option for my conditions like this:</p>
  <pre><code>router.setChannelMapping(&quot;1&quot;, &quot;retryChannel&quot;);
  router.setChannelMapping(&quot;2&quot;, &quot;retryChannel&quot;);
  router.setChannelMapping(&quot;3&quot;, &quot;logFailedChannel&quot;);
  router.setChannelMapping(&quot;4&quot;, &quot;logFailedChannel&quot;);
  </code></pre>
  <p>etc.</p>
  <p>Is there any other way to config router?</p>