Search code examples
javajmsselectoribm-mq

Message selector with receiveNoWait()


Will message selectors work with receiveNowait() method too for synchronous process. it works with receive() method but wanted to know for receiveNoWait for IBM mq. Message selector is added while creating consumer.

EDIT 1: I have tested with receiveNowait() method, and the selector is not working. I don't know the problem is with my selector or the receivenowait method. following is the selector I have used:

String messageSelector = "JMSTimestamp <= " + System.currentTimeMillis() - 180000;
 receiver = (MessageConsumer) session.createConsumer(replyQueue, messageSelector);

that means, receiver has to receive the messages only which are 3 minutes older than current time. Can anyone figure out what is the issue.

EDIT 2: after complete testing , i have found that problem is with selector, what can be the correct usage of JMSTimeStamp in selector expression?


Solution

  • pepared The system.currnetTimeMillis() value is not updated when the selector is run.

    Here you are fixing the "current" timestamp when you initialize the selector. You should do a query like "endValidityDate <= (JMSTimestamp-24601000)" for your query (same problem than any SQL query with fixed values instead of dynamic ones).