2 Replies Latest reply on Oct 9, 2012 6:20 PM by Alan Teodoro

    Getting current date in a ActiveMQ Selector

    Alan Teodoro Newbie



      I'm using the Camel component for ActiveMQ, with Spring DSL.


      I need to filter the messages I want to consume with a specific date/time. To make this comparsion, I need to retrieve the current datetime (something like SYSDATE in Oracle), but I don't know how to do it. ( I tried to compare with CURRENT_TIMESTAMP, CURRENT_DATE, new Date())


      The idea is to put a message that will be consumed and a process will be triggered. This process may not be available, so I will update the time for the next try. Then the message will be consumed only at this time. (like 5 minutes later). What I don't want is to put the message back in the queue and have it consumed right the way.


      The endpoint looks like this now:



        • 1. Re: Getting current date in a ActiveMQ Selector
          Claus Ibsen Master

          I dont think current time etc is part of the JMS spec and hence it would be an extension to ActiveMQ to have support for that.


          What type is the delay stored as on the JMS message? Is it a java.util.Date, or some other type?

          • 2. Re: Getting current date in a ActiveMQ Selector
            Alan Teodoro Newbie

            Hi Claus.


            I have the control over the type of this variable. I already tried with java.util.Date and Long.


            In the last tests we've done here, we tried using the Camel's Simple date formatter ($) the way below, but we keep receiving an warning and the consumer doesn't work.


            We're implementing this kind of control to avoid the instant comsumption of the message. We have a monitor that verifies if some of the previous processments were completed, because they run in background. Our goal here is to set up the structure of the monitor, increasing the time between the verifications during a fixed number of attempts.


            Please let us know if there is an other way to achieve this.




            <from uri="activemq:REGISTRO_ATENDIMENTO_QUEUE?selector=operationName IN ('DesfazerCancelamento','AtivarLinha', 'TrocarNumero', 'DesbloquearContrato', 'CancelarContrato','SuspenderContrato','ReativarContrato','Provisionar') AND delay &lt; $" />



            2012-10-09 18:17:00,421 | WARN | ENDIMENTO_QUEUE] | faultJmsMessageListenerContainer | 143 - org.springframework.jms - 3.0.7.RELEASE | Setup of JMS message listener invoker failed for destination 'REGISTRO_ATENDIMENTO_QUEUE' - trying to recover. Cause: operationName IN ('DesfazerCancelamento','AtivarLinha', 'TrocarNumero', 'DesbloquearContrato', 'CancelarContrato','SuspenderContrato','ReativarContrato','Provisionar') AND delay < $