title: Elegant way to setup high-priority/low-priority route consumers of sqs with Camel RoutePolicy?
body: <p>I have two SQS queues: one meant for low priority and another meant for high-priority messages. The logic is meant to be don't touch the messages on the low-priority queue unless the high-priority queue is empty. </p>
  
  <pre><code>SuspendLowPriorityRoutePolicy suspendLowPriorityRoutePolicy = new SuspendLowPriorityRoutePolicy(LOW_PRIORITY_ROUTE_ID, camelContext);
  
          from(UriBuilder.buildSqsUri(sqsProperties)).routeId(LOW_PRIORITY_ROUTE_ID)
                  .log(LoggingLevel.INFO, log, "NON-PRIORITY: ${body}");
  
          from(UriBuilder.buildPrioritySqsUri(sqsProperties)).routeId(HIGH_PRIORITY_ROUTE_ID)
                  .routePolicy(suspendLowPriorityRoutePolicy)
                  .log(LoggingLevel.INFO, log, "PRIORITY: ${body}");
  
  </code></pre>
  
  <p>Both of these consumers have their <code>concurrentConsumers</code> property set to 1, meaning they will process a single message at a time.</p>
  
  <p>Right now, I have these two routes setup to consume messages off the queues simultaneously. What I would like is for a message that comes in to the high-priority route triggers the cessation of the low-priority route. To try to get this functionality, I tried using a route policy that stops the low-priority queue when a new exchange is started on the high-priority route:</p>
  
  <p>(Snippet from <code>SuspendLowPriorityRoutePolicy</code>)</p>
  
  <pre><code> @Override
      public void onExchangeBegin(Route route, Exchange exchange) {
          Route lowPriorityRoute = context.getRoute(lowPriorityRouteId);
          ServiceStatus routeStatus = context.getRouteStatus(lowPriorityRouteId);
          if (!routeStatus.isStopped()) {
              try {
                  lock.lock();
                  log.info("High priority request came in, stopping consumer");
                  stopConsumer(lowPriorityRoute.getConsumer());
              } catch (Exception e) {
                  log.error("Exception stopping consumer " + e);
                  handleException(e);
              } finally {
                  lock.unlock();
              }
          }
      }
  </code></pre>
  
  <p>However, I am unsure about how to go about re-starting the low-priority consumer. The other hooks provided by the Camel <code>RoutePolicy</code> allow overriding <code>onExchangeDone</code> but at that point the logic should be to restart the low-priority consumer only if the high-priority queues is empty. I don't think there is a way to check if the queue is empty, we could check the <code>ApproximateNumberOfMessages</code> attribute on the exchange done hook but that may be inaccurate.</p>
  
  <p>Another thought would to have a scheduled background poller that checks the inFlightRequestsRepository of the <code>CamelContext</code> and restarts the the low priority queues only if the high priority route has no inflight requests. </p>