How to remove specific message from queue in rabbitmq - spring

I use rabbitmq. I created a queue and put 10 messages here.
I want to delete only specific one of 10 messages here. Is there a way to delete it?

No, there is no way to do that directly. Some alternatives are:
Purge the queue and add back the 9 other messages
Check for that one message on the consumer side and reject/ignore that message
Forward all the messages to another queue, except for that 1 message

The rabbitmq API doesn't seem to support deleting a separate message, but only purging all of them: sudo rabbitmqctl purge_queue <queue name>
However, you can use tricks as written here How to delete a specific message from RabbitMQ Queue?
and here is his package rabbitmq-delete-message if you are comfortable with node.js

Related

ActiveMQ How to delete only some scheduled elements

I have an ActiveMQ messaging system and i want to delete only some scheduled messages from the queue.
I can delete all the scheduled message via a ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEALL
message sent to the queue.
I can delete a message by ID by sending a AMQ_SCHEDULER_ACTION_REMOVE message.
But is there a way to delete all messages with a selector (maybe a property on the message) ?
I checked the Jolokia REST API of ActiveMQ, but it seems that informations on Scheduled messages are not available.
No that functionality is not currently supported. You would need to take a look at the source code and implement this yourself and then contribute it back to the community. There is a fine line though were trying to use a message broker as a database will turn around and bite you so I'd recommend caution on that front.
You'd need to implement a new remove directive like AMQ_SCHEDULER_ACTION_REMOVE_SELECTED and define how the selector works in that case, SQL92 string etc and then add an API on the Scheduler store interface and implement it in the Scheduler implementation in the KahaDB module.

iib 10 missing message on the local mq queue using mqoutput node

I'm newbie on IBM tool.
On my laptop, I have installed IIB v10 using a local MQ manager. I created 2 local queues on MQ: "Queue.In" and "Queue.Out".
I have a very simple scenario that I work on: I send a 'csv' file on the "Queue.In", get the message using 'MQInput node' transform the message into xml using 'mapping node', and then put the xml message to 'Queue.Out'.
Using the ‘flow exercicser’ I’m able to send my ‘csv’ file and I can see that the message get consumed and transformed to xml and send to “Queue.Out”
Problem: My xml message is successfully put in "Queue.Out", but disappear right after.
I want it to remain in the "Queue.Out".
I use “MQ explorer” to browse my queues.
Please advice.
I would always recommend using Rfhutil for Delivery and Subscription of messages onto/out of a queue. In Rfhutil you can also browse messages without taking them off the queue which can be useful.
I am unsure why the flow exerciser removes messages - this is a new feature in IIB10 so it might be that they wanted queues to be cleared after the flow execution has been completed to avoid clogging queues. I believe the point of the exerciser is to track the logic of the flows themselves not to get messages.
Hope this helps :)

How can I delete Messages from a JMS Queue?

I have several jobs that each have multiple messages queued.
The messages for each job are randomly interleaved.
If a user decides to cancel a job I want to remove all the messages that are part of that job from the queue.
I have been able to use browse()to find all the messages to remove but haven't been able to figure out how to remove them.
I tried getting rid of them by using receiveSelected() but it just hangs.
(I am using JmsTemplate)
JMS does not define administration type functions, such as deleting a message from the queue.
The programmatic way is to consume the message. Alternatively, there are messaging management tools that allow you to do this without programming.
There is no any JMS API to remove message. However seems you can invoke purge removeMessage or other operation as per your requirement on MBean org.apache.activemq:type=Broker,brokerName=amq,destinationType=Queue,destinationName=testQ to delete messages.
You are on the right track. Consuming those messages using a selector is the way to go - such as with JmsTemplate receiveSelected.
If it "hangs", it likely means you have no matching messages on the queue. Can you identify your messages on some Property, such as JMSType or other StringProperty? Make sure you can and supply a JMS Selector.
I.e. if your jobs are initiated by user X, then set some property such as "initiatingUser" to "x". Then to consume all messages, use the selector initiatingUser='X'.

Reprocess failed RabbitMQ messages manually

I have a dead-letter queue which stores failed messages. Is there have a way to manually trigger a listener to process the messages in the dead-letter queue? I’m using Spring AMQP.
Like I said, it depends on your use case, but I can assume you are looking for something from spring amqp out-of-the-box.
just have a look at BlockingQueueConsumer, you can i.e. prefetch one message if you want, then start it manually.
Please be aware that you need choose solution according to your case, maybe you just need a flag in db to mark the job is failed, or save the msg in db.

Automatically clear messages from queue in IBM MQ

I was wondering if there is a way for you to configure a queue to automatically clear messages? We are striving to partially implement a component of our architecture and want to be able to send to the queue, but have the queue automatically remove the messages that are being sent so that we don't have to run scripts, etc to perform the clean-up.
So far the only thing I have been able to find is to run CLEAR QLOCAL or set the messages to expire from the publishing application.
For you use case there are a few options in IBM MQ:
Create a QALIAS that points to a TOPIC object which has a topic string with no subscribers, messages put to the QA will just disappear.
Have the sending application set message expiry.
Use the IBM MQ CAPEXPRY feature to administratively force message expiry at the queue level.
Run a script to issue CLEAR QLOCAL against the queue. There can not be open handles on the queue for this to work.
Programmatically issue the equivalent PCF command to CLEAR QLOCAL against the queue. There cannot be open handles on the queue for this to work.
Run the IBM MQ dmpmqmsg utility against the queue to read and discard the messages.

Resources