1
votes

Is there a way to configure a JMS message queue to drop all received messages automatically? (In other words: for the sender it must look like the message arrived ok, but the queue should silently drop it. That is, the queue should behave like "/dev/null") In case that matters, I'm most interested in IBM MQ, however, if JMS specification offers this possibility, that would be even better.

Since I already tried searching, and did not find such a possibility, I suspect the answer is "no". So an answer that confirms that this is the case (and I'm not missing anything) is also valid for me.

Use case: test a system, that sends messages to a real JMS queue, which (in the test setup) are not read out by any other program. (I do not want to mock the JMS queue, to keep the test environment as close to production as possible. For the same reason, it is also not a valid solution to e.g. set "time to live" for the messages on the client side.)

2
What version of IBM MQ is running on the queue manger?JoshMc
I'm not sure... would there be a good solution for some of version, that is not available for the other?Attilio
The pub sub solution provided by @JasonE would work with v7.0 and later and not with v6 and lower. V7.5 is the lowest currently supported version but I asked because there are still many people using very old unsupported versions of MQ. The solution Jason provided is what I was going to suggest assuming you were running v7 or later. Based on your comments you have a solution in place like Roger suggested but were looking for something like Jason accepted, I would suggest you accept Jason's answer.JoshMc

2 Answers

2
votes

How about making a queue which you put to being an alias to a topic with noone listening on it?

e.g.:

def qalias(MYQUEUE) target(DUMMYTOPIC) targtype(TOPIC)
def topic(DUMMYTOPIC) topicstr(DUMMYTOPIC)

Then you can put to the queue, it becomes a publish and if noone is listening on the queue it vanishes. amqsput MYQUEUE QM for example will work fine.

When you want to then consume the messages, change the QALIAS to either point to a real queue, or replace the QALIAS definition with a QLOCAL for example.

The only downside is if anyone is subscribed to every topic, but for testing purposes you can

0
votes

If you want a different approach where you can control (turn off/on) the flow of messages being deleted/removed, then an MQ Service and my 'emtyq' program is another option.

Here's a write up I did a while ago on the subject: http://www.capitalware.com/rl_blog/?p=3680