title: Java monitoring activemq but without polling the queue
body: <p>I need to program something that monitors an activemq queue in java. This means I need to log when a message is enqueued on the queue and when a message is dequeued. My program must not send messages or receives messages, it only needs to log.</p>
  
  <p>I found out to push messages and receive messages but this is not what I want to do, just log if an external process puts messages on or off the queue.</p>
  
  <p>To make it more clear I made a drawing
  <img src="https://i.stack.imgur.com/nqmTh.png" alt="enter image description here"></p>
  
  <p>I use apache camel to make the integration,
  my routebuilder looks like</p>
  
  <pre><code>public void configure() throws Exception {
          Processor queueProcessor = new QueueProcessor();
  
          from("activemq:queue:KBC").process(queueProcessor);
      }
  </code></pre>
  
  <p>it calls the folowwing processor</p>
  
  <pre><code>@Override
      public void process(Exchange exchange) throws Exception {
          Trax_EventDao dao = new Trax_EventDao();
          dao.insert(new Trax_Event("Queue",exchange.getExchangeId(),"UP","KBC", new Time(new Date().getTime())));
      }
  </code></pre>
  
  <p>The dao handles a database connection and makes an insert of a record</p>
  
  <p>The actual problem is that  when I push a message on the queue and the program runs, the message got logged which is okay, but it also get polled immediately, which is not okay.
  How can I make the insert without the message being polled?</p>