how get messages from activemq dlq? - activemq

I'm trying to write a script that pulls messages from activeMQ queue and purge them after. I tried looking it up online but couldn't find any examples to teach me how to do it. I'm want to know how can I connect to DLQ and how can I purge it?
Any help?
Thanks in advance

DLQ is like any topic or queue and you can subscribe to it like any topic or queue and consume messages accumulated. Here is the list [http://activemq.apache.org/advisory-message.html][1]
The name of the DLQ to subscribe to it is ActiveMQ.DLQ if you not have an individualDeadLetterStrategy , you subscribe and do your business onMessage method .
[http://activemq.apache.org/message-redelivery-and-dlq-handling.html][2]
New Advisories in 5.4 ActiveMQ.Advisory.MessageDLQd.* accessible by org.apache.activemq.advisory.AdvisorySupport.getMessageDLQdAdvisoryTopic(ActiveMQDestination);

Related

Publish same message to different queues in RabbitMQ using Masstransit

any body can help me finding how can I send the message to differents queues (depending on business logic) to differents queues in RabbitMQ, using Masstransit
I have read the documentation I didn't found how I can specify the queue destination name
thank you
You might want to read the documentation again. If you want to send to a specific queue, you actually have to send to the exchange for that queue created by MassTransit.
Use the ISendEndpointProvider (or ConsumeContext):
Call await GetSendEndpoint(new Uri("exchange:name")) or await GetSendEndpoint(new Uri("queue:name")) to get the ISendEndpoint.
Call Send(...) to send the message to the exchange or queue.

What is the best approach for dealing with RabbitMQ DLQ messages in Spring AMQP

I am using Spring AMQP to listen RabbitMQ queue. While listening queue, depending on business logic, my service can throw RuntimeException and in this case message will retry several times. After max count retries, message will stay in DLQ. And I am wondering, what is the best approach to deal with these messages in DLQ? I read from blogs that I can use ParkingLot Queue. But also in this case, how to monitor the queue and notify people about dead-letter messages?
P.S. Sorry for my English. Hope that I was able to explain my problem :)
You can use the RabbitMQ REST api (Hop client) to get the status of the DLQ.
You can also use Spring's RabbitAdmin.getQueueProperties("my.dlq") to get the message count.
https://docs.spring.io/spring-amqp/docs/current/reference/html/#broker-configuration
Other options include adding another listener on the DLQ and run it periodically to either send it back to the original queue or send it to a parking lot queue if it fails too many times.
There's an example of that in the spring cloud stream documentation.

Consumer Count / pending Message Count from Queue + ActiveMQ + Java

I have to develop the Utility in Java which will use the ActiveMQ API to get the properties of Queue/Topic to get the No of Consumers / No of Pending Messages and also is there any way I can delete any Message thru Code from Queue ?
I would recommend to use the Statistics Plugin to get the consumer count, pending counts etc.
About deleting/removing any particular message from queue, I would recommend not to do that in a separate program but just let your message consumers handle such messages. That would be more maintainable approach I think.
All the below details are with respect to Queue API of ActiveMQ, you can find similar things for topic as well
No of Pending messages can be found by using getMessages().size()
No of consumers can be found by getConSumers().size()
yes , we can delete messages onto queue from Java code, but we need
MessageReference or the messageId or a suitable message Selector for this to happen, you can have a look at official
documentation of removeMessage(...) and
removeMatchingMessages(...) here
hope this helps!
Good luck!

activemq round robin between queues or topics

I'm trying to achieve load balancing between different types of messages. I would not know in advance what the messages coming in might be until they hit the queue. I know I can try resequencing the messages, but I was thinking that maybe if there was a way to have the various consumers round robin between either queues or between topics, this would solve my problem.
The main problem i'm trying to solve is that I have many services sending messages to one queue with many consumers feeding off one queue. I do not want one type of service monopolizing the entire worker cluster. Again I don't know in advance what the messages that are going to hit the queue are going to be.
To try to clearly repeat my question:
Is there a way to tell the consumers to round robin between either existing queues or topics?
Thank you in advance.
I found the answer to my question on another post just had to know to look there. I resolved my problem by not creating AMQ consumer but a JMS listener with a composite destination as specified in this post: jms-listener-dynamically-choose-destinations. It turns out the JMS listener automatically round robins though all the queues you assign to it.
Consumers on a Queue will already do round robin processing of the messages on the Queue. The one thing to keep in mind is consumer prefetch which can allow one consumer to grab many messages before others arrive on the Queue so you may need to adjust prefetch depending on your scenario.
Read up on the differences between Queue and Topic here.

What is the meaning of "Enqueued" and "Dequeued" messages in "DLQ"?

Hi guys ,
I'm now working with ActiveMQ and wanna know what is the meaning of enqueued/dequeued messages in DQL. As i know, DLQ doesn't have a consumer to produce any messages. So, there shouldn't have any enqueued or dequeued messages in DLQ queue. Am I right ? or there is another process to perform with pending queues in DLQ. Please advise.
Thanks,
Stop
A DLQ is just a JMS Queue behind the scenes, you can send message to it and consume messages from it just like any other queue...hence the stats, etc.