0

I am developing a windows service which will read the messages from MQ using IBM.XMS listeners.

I need to read only messages which are older than 120 seconds. I have successfully created a listener which is reading all the messages coming into the queue but I am not able to put a filter on the listener.

Below is my code which is reading all the messages

ISession sess = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
IDestination readqueue = sess.CreateQueue("XYZ");
IMessageConsumer consumer = sess.CreateConsumer(readqueue);

MessageListener list = new MessageListener(OnMessage);
consumer.MessageListener = list;

connection.Start();

This code is reading all messages, which I do not want.

Caleb Brinkman
  • 2,489
  • 3
  • 26
  • 40
  • I want to receive message coming into the queue . I want to write a windows service or listener which will receive message into queue but I can't find any document regarding this. Can anyone suggests any document regarding this – ratna Jun 08 '18 at 12:29

1 Answers1

0

I think a same question was asked on IBM developerWorks forum also.

I am not sure what your business logic is but I would suggest you explore the option of sender of the messages setting message expiry to value you want, 2 minutes in this case. When message expiry is set, any message not consumed before the expiry will not be delivered to application. So you don't need another application to clear the messages older than 120 seconds.

Shashi
  • 14,980
  • 2
  • 33
  • 52
  • The question says, that the goal is to read messages older than 120 secs, so basically the opposite of message expiry is needed here. – Attila Repasi Dec 30 '15 at 12:31
  • The goal is just to clear the queue of messages older than 120 seconds. No processing of such messages is to be done. Expiry is best suited in this case. – Shashi Dec 30 '15 at 13:18
  • I agree that expiry is best option and same I have used in other projects. Here third party not ready to set expiry. Scripts client is not ready. So I need to read messages and I need to log the response in message in some database. So basically I need to read messages which are older that 2 mins. – Amita Garg Dec 30 '15 at 15:13
  • The dmpmqmsg/Qload utility may be useful. Source code is available on GitHub. Take a look , you may get some ideas. – Shashi Dec 30 '15 at 15:17