activemq message redelivery - activemq

I would like to know whether it is possible to retain one message in the queue without it getting re-delivered by activemq after one consumption for a certain time i.e message m1 once consumed and the session is closed. I want m1 not to be re delivered by activemq for some some time. After the time it can be re-delivered.
Thanks in advance.
Regards,
Arijit

See if this helps http://activemq.apache.org/redelivery-policy.html

Related

How to get/know a message that is processing in RabbitMQ?

I need to know if it's possible to know or get a message from RabbitMQ (consumers) which is processing (maybe if it's taking long time). But, I don't want to stop the service. I hope my question is clear enough.
I guess you mean if RabbitMQ provides any build-in notification or tracking about whether a specific message is being processed or not. The answer is No. But you should easily be able to implement one by your own. For instance, when begin to process a message in the consumer, the consumer could send a notification message to a notification queue.

How do I auto expire messages that dont have a consumer?

I need the broker to delete all messages that dont have any consumers waiting. I seem to recall that this should be a default behavior, shouldn't it?
There are two approcahes to define a time-to-live for ativeMQ messages,if in this time period message is not consumed then it will expire.
you can have two approaches for this
producer.setTimeToLive(Long timeToLiveInMilliSeconds)
Above approach will apply to all messages from this producer or if you want for specific messages you can do it like this
producer.send(Destination destination,Message message,int deliveryMode,int priority,long timeToLive)
apart from this,there is no default configuration that message gets deleted as soon as it is placed on a queue and there is no consumer for that queue
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 makes an AMQ queue's pending message number negative?

After I purged the message of a queue (not a topic), the pending message number of this queue in Active MQ Admin console changed to negative.
I assumed the pending message number of any queue ought to be positive. Is it issue of purging? Or is it a bug of activemq?
It seems to be a bug in ActiveMQ. I've personally witnessed this bug on numerous occasions when purging a queue. It does not seem to affect actual message delivery however.
There are a number of open issues in the ActiveMQ issue tracker related to this problem. You can vote them up if you want:
https://issues.apache.org/jira/browse/AMQ-3472
https://issues.apache.org/jira/browse/AMQ-3111
This problem is solved in ActiveMQ 5.8 :
https://issues.apache.org/jira/browse/AMQ-4598
Purging doesnt stop the mq from processing the queued jobs. Restart the ActiveMQ is only getting rid of the existing jobs. The down side to this is, this will make all the numbers reset to default.

How does AMQ's redeliver work? Does it hold a consumer completely during the redelivery process?

Assuming that we only have one consumer and our redelivery policy will allow the message to be redelivered for a quite long time.
I've tried a scenario where I sent two messages(different type), one is designed to be redelivered and the other can be consumed normally.
It seems the normal message will be blocked if it is delivered later than the redelivered one.
It will not be consumed until the redelivered message has tried many times reaching the maximum redeliver times. That would lead to a situation where a easy-to-consumed message must wait a long time to be consumed..
I'm wondering how the AMQ redeliver work. When a message is redelivered in a consumer, the other message can be sent to this consumer until current message has been consumed or timeout(to DLQ).
Can someone help ? Thanks,
ActiveMQ's overriding concern when redelivering messages is to honour message ordering on a queue.
Given two messages A and B, which get sent to a queue with a defined redelivery policy as you describe: if a client fails processing A, that message will get placed back on the queue and no other messages will be consumed until A is consumed successfully.
Check out the ActiveMQ Message Redelivery and DLQ Handling section for further details.
Please remember to vote this response up if it answers your question.
For this case it is possible to set the ActiveConnectionFactory to onBlockingRedelivery.
Find details in de ActiveMq Api documentation: