Message selector with receiveNoWait()

孤人 提交于 2019-12-25 02:47:06

问题


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?


回答1:


receive(), receive(long timeout) and receiveNoWait() should work exactly the same in terms of what is delivered. In fact several implementations implement one by calling another method.




回答2:


I can't speak to the IBM MQ implementation specifically, but from a JMS perspective there's nothing in the JMS specification that limits the use of selectors with receiveNoWait so I would expect it to work in any compliant implementation.



来源:https://stackoverflow.com/questions/55023274/message-selector-with-receivenowait

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!